* Removing opentracing

* Fixing CI
Этот коммит содержится в:
Jesús Espino
2025-01-29 07:45:13 +01:00
коммит произвёл GitHub
родитель 565c8aa42d
Коммит f1acdce42c
30 изменённых файлов: 26 добавлений и 36663 удалений

Просмотреть файл

@@ -1450,7 +1450,7 @@ func hasPermissionToReadGroupMembers(c *web.Context, groupID string) *model.AppE
//
// err := licensedAndConfiguredForGroupBySource(c.App, group.Source)
// err.Where = "Api4.getGroup"
func licensedAndConfiguredForGroupBySource(app app.AppIface, source model.GroupSource) *model.AppError {
func licensedAndConfiguredForGroupBySource(app *app.App, source model.GroupSource) *model.AppError {
lic := app.Srv().License()
if lic == nil {

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@@ -51,7 +51,6 @@ func GetCommandProvider(name string) CommandProvider {
return nil
}
// @openTracingParams teamID, skipSlackParsing
func (a *App) CreateCommandPost(c request.CTX, post *model.Post, teamID string, response *model.CommandResponse, skipSlackParsing bool) (*model.Post, *model.AppError) {
if skipSlackParsing {
post.Message = response.Text
@@ -81,7 +80,6 @@ func (a *App) CreateCommandPost(c request.CTX, post *model.Post, teamID string,
return post, nil
}
// @openTracingParams teamID
// previous ListCommands now ListAutocompleteCommands
func (a *App) ListAutocompleteCommands(teamID string, T i18n.TranslateFunc) ([]*model.Command, *model.AppError) {
commands := make([]*model.Command, 0, 32)
@@ -179,7 +177,6 @@ func (a *App) ListAllCommands(teamID string, T i18n.TranslateFunc) ([]*model.Com
return commands, nil
}
// @openTracingParams args
func (a *App) ExecuteCommand(c request.CTX, args *model.CommandArgs) (*model.CommandResponse, *model.AppError) {
trigger := ""
message := ""

Просмотреть файл

@@ -1,12 +0,0 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// Code generated by "make app-layers"
// DO NOT EDIT
package app
// AppIface is extracted from App struct and contains all it's exported methods. It's provided to allow partial interface passing and app layers creation.
type AppIface interface {
{{.Content}}
}

Просмотреть файл

@@ -1,285 +0,0 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package main
import (
"bytes"
"flag"
"fmt"
"go/ast"
"go/parser"
"go/token"
"io"
"log"
"os"
"path"
"regexp"
"strings"
"text/template"
"golang.org/x/tools/imports"
)
var (
reserved = []string{"AcceptLanguage", "AccountMigration", "Cluster", "Compliance", "Context", "DataRetention", "Elasticsearch", "HTTPService", "ImageProxy", "IpAddress", "Ldap", "Log", "MessageExport", "Metrics", "Notification", "NotificationsLog", "Path", "RequestId", "Saml", "Session", "SetIpAddress", "SetRequestId", "SetSession", "SetStore", "SetT", "Srv", "Store", "T", "Timezones", "UserAgent", "SetUserAgent", "SetAcceptLanguage", "SetPath", "SetContext", "SetServer", "GetT"}
outputFile string
inputFile string
outputFileTemplate string
basicTypes = map[string]bool{"int": true, "uint": true, "string": true, "float": true, "bool": true, "byte": true, "int64": true, "uint64": true, "error": true}
textRegexp = regexp.MustCompile(`\w+$`)
)
const (
OpenTracingParamsMarker = "@openTracingParams"
AppErrorType = "*model.AppError"
ErrorType = "error"
)
func isError(typeName string) bool {
return strings.Contains(typeName, AppErrorType) || strings.Contains(typeName, ErrorType)
}
func init() {
flag.StringVar(&inputFile, "in", path.Join("..", "app_iface.go"), "App interface file")
flag.StringVar(&outputFile, "out", path.Join("..", "opentracing_layer.go"), "Output file")
flag.StringVar(&outputFileTemplate, "template", "opentracing_layer.go.tmpl", "Output template file")
}
func main() {
flag.Parse()
code, err := generateLayer("OpenTracingAppLayer", outputFileTemplate)
if err != nil {
log.Fatal(err)
}
formattedCode, err := imports.Process(outputFile, code, &imports.Options{Comments: true})
if err != nil {
log.Fatal(err)
}
err = os.WriteFile(outputFile, formattedCode, 0644)
if err != nil {
log.Fatal(err)
}
}
type methodParam struct {
Name string
Type string
}
type methodData struct {
ParamsToTrace map[string]bool
Params []methodParam
Results []string
}
type storeMetadata struct {
Name string
Methods map[string]methodData
}
func fixTypeName(t string) string {
// don't want to dive into AST to parse this, add exception
if t == "...func(*UploadFileTask)" {
t = "...func(*app.UploadFileTask)"
}
if strings.Contains(t, ".") || strings.Contains(t, "{}") || t == "map[string]any" {
return t
}
typeOnly := textRegexp.FindString(t)
if _, basicType := basicTypes[typeOnly]; !basicType {
t = t[:len(t)-len(typeOnly)] + "app." + typeOnly
}
return t
}
func formatNode(src []byte, node ast.Expr) string {
return string(src[node.Pos()-1 : node.End()-1])
}
func extractMethodMetadata(method *ast.Field, src []byte) methodData {
params := []methodParam{}
paramsToTrace := map[string]bool{}
results := []string{}
e := method.Type.(*ast.FuncType)
if method.Doc != nil {
for _, comment := range method.Doc.List {
s := comment.Text
if idx := strings.Index(s, OpenTracingParamsMarker); idx != -1 {
for _, p := range strings.Split(s[idx+len(OpenTracingParamsMarker):], ",") {
paramsToTrace[strings.TrimSpace(p)] = true
}
}
}
}
if e.Params != nil {
for _, param := range e.Params.List {
for _, paramName := range param.Names {
paramType := fixTypeName(formatNode(src, param.Type))
params = append(params, methodParam{Name: paramName.Name, Type: paramType})
}
}
}
if e.Results != nil {
for _, r := range e.Results.List {
typeStr := fixTypeName(formatNode(src, r.Type))
if len(r.Names) > 0 {
for _, k := range r.Names {
results = append(results, fmt.Sprintf("%s %s", k.Name, typeStr))
}
} else {
results = append(results, typeStr)
}
}
}
for paramName := range paramsToTrace {
found := false
for _, param := range params {
if param.Name == paramName || strings.HasPrefix(paramName, param.Name+".") {
found = true
break
}
}
if !found {
log.Fatalf("Unable to find a parameter called '%s' (method '%s') that is mentioned in the '%s' comment. Maybe it was renamed?", paramName, method.Names[0].Name, OpenTracingParamsMarker)
}
}
return methodData{Params: params, Results: results, ParamsToTrace: paramsToTrace}
}
func extractStoreMetadata() (*storeMetadata, error) {
// Create the AST by parsing src.
fset := token.NewFileSet() // positions are relative to fset
file, err := os.Open(inputFile)
if err != nil {
return nil, fmt.Errorf("unable to open %s file: %w", inputFile, err)
}
src, err := io.ReadAll(file)
if err != nil {
return nil, err
}
defer file.Close()
f, err := parser.ParseFile(fset, "../app_iface.go", src, parser.AllErrors|parser.ParseComments)
if err != nil {
return nil, err
}
metadata := storeMetadata{Methods: map[string]methodData{}}
ast.Inspect(f, func(n ast.Node) bool {
switch x := n.(type) {
case *ast.TypeSpec:
if x.Name.Name == "AppIface" {
for _, method := range x.Type.(*ast.InterfaceType).Methods.List {
methodName := method.Names[0].Name
found := false
for _, reservedMethod := range reserved {
if methodName == reservedMethod {
found = true
break
}
}
if found {
continue
}
metadata.Methods[methodName] = extractMethodMetadata(method, src)
}
}
}
return true
})
return &metadata, err
}
func generateLayer(name, templateFile string) ([]byte, error) {
out := bytes.NewBufferString("")
metadata, err := extractStoreMetadata()
if err != nil {
return nil, err
}
metadata.Name = name
myFuncs := template.FuncMap{
"joinResults": func(results []string) string {
return strings.Join(results, ", ")
},
"joinResultsForSignature": func(results []string) string {
return fmt.Sprintf("(%s)", strings.Join(results, ", "))
},
"genResultsVars": func(results []string) string {
vars := make([]string, 0, len(results))
for i := range results {
vars = append(vars, fmt.Sprintf("resultVar%d", i))
}
return strings.Join(vars, ", ")
},
"errorToBoolean": func(results []string) string {
for i, typeName := range results {
if isError(typeName) {
return fmt.Sprintf("resultVar%d == nil", i)
}
}
return "true"
},
"errorPresent": func(results []string) bool {
for _, typeName := range results {
if isError(typeName) {
return true
}
}
return false
},
"errorVar": func(results []string) string {
for i, typeName := range results {
if isError(typeName) {
return fmt.Sprintf("resultVar%d", i)
}
}
return ""
},
"shouldTrace": func(params map[string]bool, param string) string {
if _, ok := params[param]; ok {
return fmt.Sprintf(`span.SetTag("%s", %s)`, param, param)
}
for pName := range params {
if strings.HasPrefix(pName, param+".") {
return fmt.Sprintf(`span.SetTag("%s", %s)`, pName, pName)
}
}
return ""
},
"joinParams": func(params []methodParam) string {
paramsNames := []string{}
for _, param := range params {
s := param.Name
if strings.HasPrefix(param.Type, "...") {
s += "..."
}
paramsNames = append(paramsNames, s)
}
return strings.Join(paramsNames, ", ")
},
"joinParamsWithType": func(params []methodParam) string {
paramsWithType := []string{}
for _, param := range params {
paramsWithType = append(paramsWithType, fmt.Sprintf("%s %s", param.Name, param.Type))
}
return strings.Join(paramsWithType, ", ")
},
}
t := template.Must(template.New("opentracing_layer.go.tmpl").Funcs(myFuncs).ParseFiles(templateFile))
err = t.Execute(out, metadata)
if err != nil {
return nil, err
}
return out.Bytes(), nil
}

Просмотреть файл

@@ -1,144 +0,0 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// Code generated by "make app-layers"
// DO NOT EDIT
package opentracing
import (
"github.com/opentracing/opentracing-go/ext"
spanlog "github.com/opentracing/opentracing-go/log"
)
type {{.Name}} struct {
app app.AppIface
srv *app.Server
log *mlog.Logger
notificationsLog *mlog.Logger
accountMigration einterfaces.AccountMigrationInterface
cluster einterfaces.ClusterInterface
compliance einterfaces.ComplianceInterface
dataRetention einterfaces.DataRetentionInterface
searchEngine *searchengine.Broker
ldap einterfaces.LdapInterface
messageExport einterfaces.MessageExportInterface
metrics einterfaces.MetricsInterface
notification einterfaces.NotificationInterface
saml einterfaces.SamlInterface
httpService httpservice.HTTPService
imageProxy *imageproxy.ImageProxy
timezones *timezones.Timezones
ctx context.Context
}
{{range $index, $element := .Methods}}
func (a *{{$.Name}}) {{$index}}({{$element.Params | joinParamsWithType}}) {{$element.Results | joinResultsForSignature}} {
origCtx := a.ctx
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.{{$index}}")
a.ctx = newCtx
a.app.Srv().Store().SetContext(newCtx)
defer func() {
a.app.Srv().Store().SetContext(origCtx)
a.ctx = origCtx
}()
{{range $paramIdx, $param := $element.Params}}
{{ shouldTrace $element.ParamsToTrace $param.Name }}
{{end}}
defer span.Finish()
{{- if $element.Results | len | eq 0}}
a.app.{{$index}}({{$element.Params | joinParams}})
{{else}}
{{$element.Results | genResultsVars}} := a.app.{{$index}}({{$element.Params | joinParams}})
{{if $element.Results | errorPresent}}
if {{$element.Results | errorVar}} != nil {
span.LogFields(spanlog.Error({{$element.Results | errorVar}}))
ext.Error.Set(span, true)
}
{{end}}
return {{$element.Results | genResultsVars -}}
{{end}}}
{{end}}
func NewOpenTracingAppLayer(childApp app.AppIface, ctx context.Context) *{{.Name}} {
newApp := {{.Name}}{
app: childApp,
ctx: ctx,
}
newApp.srv = childApp.Srv()
newApp.log = childApp.Log()
newApp.notificationsLog = childApp.NotificationsLog()
newApp.accountMigration = childApp.AccountMigration()
newApp.cluster = childApp.Cluster()
newApp.compliance = childApp.Compliance()
newApp.dataRetention = childApp.DataRetention()
newApp.searchEngine = childApp.SearchEngine()
newApp.ldap = childApp.Ldap()
newApp.messageExport = childApp.MessageExport()
newApp.metrics = childApp.Metrics()
newApp.notification = childApp.Notification()
newApp.saml = childApp.Saml()
newApp.httpService = childApp.HTTPService()
newApp.imageProxy = childApp.ImageProxy()
newApp.timezones = childApp.Timezones()
return &newApp
}
func (a *{{.Name}}) Srv() *app.Server {
return a.srv
}
func (a *{{.Name}}) Log() *mlog.Logger {
return a.log
}
func (a *{{.Name}}) NotificationsLog() *mlog.Logger {
return a.notificationsLog
}
func (a *{{.Name}}) AccountMigration() einterfaces.AccountMigrationInterface {
return a.accountMigration
}
func (a *{{.Name}}) Cluster() einterfaces.ClusterInterface {
return a.cluster
}
func (a *{{.Name}}) Compliance() einterfaces.ComplianceInterface {
return a.compliance
}
func (a *{{.Name}}) DataRetention() einterfaces.DataRetentionInterface {
return a.dataRetention
}
func (a *{{.Name}}) Ldap() einterfaces.LdapInterface {
return a.ldap
}
func (a *{{.Name}}) MessageExport() einterfaces.MessageExportInterface {
return a.messageExport
}
func (a *{{.Name}}) Metrics() einterfaces.MetricsInterface {
return a.metrics
}
func (a *{{.Name}}) Notification() einterfaces.NotificationInterface {
return a.notification
}
func (a *{{.Name}}) Saml() einterfaces.SamlInterface {
return a.saml
}
func (a *{{.Name}}) HTTPService() httpservice.HTTPService {
return a.httpService
}
func (a *{{.Name}}) ImageProxy() *imageproxy.ImageProxy {
return a.imageProxy
}
func (a *{{.Name}}) Timezones() *timezones.Timezones {
return a.timezones
}
func (a *{{.Name}}) SetServer(srv *app.Server) {
a.srv = srv
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@@ -11,7 +11,7 @@ import (
"github.com/mattermost/mattermost/server/public/shared/request"
)
func PostPriorityCheckWithApp(where string, a AppIface, userId string, priority *model.PostPriority, rootId string) *model.AppError {
func PostPriorityCheckWithApp(where string, a *App, userId string, priority *model.PostPriority, rootId string) *model.AppError {
user, appErr := a.GetUser(userId)
if appErr != nil {
return appErr
@@ -84,7 +84,7 @@ func postPriorityCheck(
return nil
}
func PostHardenedModeCheckWithApp(a AppIface, isIntegration bool, props model.StringInterface) *model.AppError {
func PostHardenedModeCheckWithApp(a *App, isIntegration bool, props model.StringInterface) *model.AppError {
hardenedModeEnabled := *a.Config().ServiceSettings.ExperimentalEnableHardenedMode
return postHardenedModeCheck(hardenedModeEnabled, isIntegration, props)
}
@@ -99,7 +99,7 @@ func postHardenedModeCheck(hardenedModeEnabled, isIntegration bool, props model.
return nil
}
func userCreatePostPermissionCheckWithApp(c request.CTX, a AppIface, userId, channelId string) *model.AppError {
func userCreatePostPermissionCheckWithApp(c request.CTX, a *App, userId, channelId string) *model.AppError {
hasPermission := false
if a.HasPermissionToChannel(c, userId, channelId, model.PermissionCreatePost) {
hasPermission = true

Просмотреть файл

@@ -74,7 +74,6 @@ import (
"github.com/mattermost/mattermost/server/v8/platform/services/searchengine/bleveengine/indexer"
"github.com/mattermost/mattermost/server/v8/platform/services/sharedchannel"
"github.com/mattermost/mattermost/server/v8/platform/services/telemetry"
"github.com/mattermost/mattermost/server/v8/platform/services/tracing"
"github.com/mattermost/mattermost/server/v8/platform/services/upgrader"
"github.com/mattermost/mattermost/server/v8/platform/shared/filestore"
"github.com/mattermost/mattermost/server/v8/platform/shared/mail"
@@ -153,8 +152,6 @@ type Server struct {
IPFiltering einterfaces.IPFilteringInterface
OutgoingOAuthConnection einterfaces.OutgoingOAuthConnectionInterface
tracer *tracing.Tracer
ch *Channels
}
@@ -306,14 +303,6 @@ func NewServer(options ...Option) (*Server, error) {
}
}
if *s.platform.Config().ServiceSettings.EnableOpenTracing {
tracer, err2 := tracing.New()
if err2 != nil {
return nil, err2
}
s.tracer = tracer
}
s.pushNotificationClient = s.httpService.MakeClient(true)
s.outgoingWebhookClient = s.httpService.MakeClient(false)
@@ -689,12 +678,6 @@ func (s *Server) Shutdown() {
s.RemoveLicenseListener(s.loggerLicenseListenerId)
s.RemoveClusterLeaderChangedListener(s.clusterLeaderListenerId)
if s.tracer != nil {
if err := s.tracer.Close(); err != nil {
s.Log().Warn("Unable to cleanly shutdown opentracing client", mlog.Err(err))
}
}
err := s.telemetryService.Shutdown()
if err != nil {
s.Log().Warn("Unable to cleanly shutdown telemetry client", mlog.Err(err))

Просмотреть файл

@@ -171,7 +171,7 @@ func ManualTest(c *web.Context, w http.ResponseWriter, r *http.Request) {
}
}
func getChannelID(a app.AppIface, channelname string, teamid string, userid string) (string, bool) {
func getChannelID(a *app.App, channelname string, teamid string, userid string) (string, bool) {
// Grab all the channels
channels, err := a.Srv().Store().Channel().GetChannels(teamid, userid, &model.ChannelSearchOpts{
IncludeDeleted: false,

Просмотреть файл

@@ -19,8 +19,7 @@ import (
)
const (
OpenTracingParamsMarker = "@openTracingParams"
ErrorType = "error"
ErrorType = "error"
)
func isError(typeName string) bool {
@@ -31,9 +30,6 @@ func main() {
if err := buildTimerLayer(); err != nil {
log.Fatal(err)
}
if err := buildOpenTracingLayer(); err != nil {
log.Fatal(err)
}
if err := buildRetryLayer(); err != nil {
log.Fatal(err)
}
@@ -65,28 +61,14 @@ func buildTimerLayer() error {
return os.WriteFile(path.Join("timerlayer", "timerlayer.go"), formatedCode, 0644)
}
func buildOpenTracingLayer() error {
code, err := generateLayer("OpenTracingLayer", "opentracing_layer.go.tmpl")
if err != nil {
return err
}
formatedCode, err := format.Source(code)
if err != nil {
return err
}
return os.WriteFile(path.Join("opentracinglayer", "opentracinglayer.go"), formatedCode, 0644)
}
type methodParam struct {
Name string
Type string
}
type methodData struct {
Params []methodParam
Results []string
ParamsToTrace map[string]bool
Params []methodParam
Results []string
}
type subStore struct {
@@ -102,20 +84,9 @@ type storeMetadata struct {
func extractMethodMetadata(method *ast.Field, src []byte) methodData {
params := []methodParam{}
results := []string{}
paramsToTrace := map[string]bool{}
ast.Inspect(method.Type, func(expr ast.Node) bool {
switch e := expr.(type) {
case *ast.FuncType:
if method.Doc != nil {
for _, comment := range method.Doc.List {
s := comment.Text
if idx := strings.Index(s, OpenTracingParamsMarker); idx != -1 {
for _, p := range strings.Split(s[idx+len(OpenTracingParamsMarker):], ",") {
paramsToTrace[strings.TrimSpace(p)] = true
}
}
}
}
if e.Params != nil {
for _, param := range e.Params.List {
for _, paramName := range param.Names {
@@ -128,23 +99,10 @@ func extractMethodMetadata(method *ast.Field, src []byte) methodData {
results = append(results, string(src[result.Type.Pos()-1:result.Type.End()-1]))
}
}
for paramName := range paramsToTrace {
found := false
for _, param := range params {
if param.Name == paramName {
found = true
break
}
}
if !found {
log.Fatalf("Unable to find a parameter called '%s' (method '%s') that is mentioned in the '%s' comment. Maybe it was renamed?", paramName, method.Names[0].Name, OpenTracingParamsMarker)
}
}
}
return true
})
return methodData{Params: params, Results: results, ParamsToTrace: paramsToTrace}
return methodData{Params: params, Results: results}
}
func extractStoreMetadata() (*storeMetadata, error) {

Просмотреть файл

@@ -1,84 +0,0 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// Code generated by "make store-layers"
// DO NOT EDIT
package opentracinglayer
import (
"context"
"github.com/mattermost/mattermost/server/public/model"
"github.com/mattermost/mattermost/server/public/shared/request"
"github.com/mattermost/mattermost/server/v8/platform/services/tracing"
"github.com/mattermost/mattermost/server/v8/channels/store"
"github.com/opentracing/opentracing-go/ext"
spanlog "github.com/opentracing/opentracing-go/log"
)
type {{.Name}} struct {
store.Store
{{range $index, $element := .SubStores}} {{$index}}Store store.{{$index}}Store
{{end}}
}
{{range $index, $element := .SubStores}}func (s *{{$.Name}}) {{$index}}() store.{{$index}}Store {
return s.{{$index}}Store
}
{{end}}
{{range $index, $element := .SubStores}}type {{$.Name}}{{$index}}Store struct {
store.{{$index}}Store
Root *{{$.Name}}
}
{{end}}
{{range $substoreName, $substore := .SubStores}}
{{range $index, $element := $substore.Methods}}
func (s *{{$.Name}}{{$substoreName}}Store) {{$index}}({{$element.Params | joinParamsWithType}}) {{$element.Results | joinResultsForSignature}} {
origCtx := s.Root.Store.Context()
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "{{$substoreName}}Store.{{$index}}")
s.Root.Store.SetContext(newCtx)
defer func(){
s.Root.Store.SetContext(origCtx)
}()
{{range $paramName, $param := $element.Params}}
{{if index $element.ParamsToTrace $param.Name }}
span.SetTag("{{$param.Name}}", {{$param.Name}})
{{end}}
{{end}}
defer span.Finish()
{{- if $element.Results | len | eq 0}}
s.{{$substoreName}}Store.{{$index}}({{$element.Params | joinParams}})
{{else}}
{{genResultsVars $element.Results false }} := s.{{$substoreName}}Store.{{$index}}({{$element.Params | joinParams}})
{{- if $element.Results | errorPresent }}
if {{$element.Results | errorVar}} != nil {
span.LogFields(spanlog.Error({{$element.Results | errorVar}}))
ext.Error.Set(span, true)
}
{{end}}
return {{ genResultsVars $element.Results false -}}
{{end}}
}
{{end}}
{{end}}
{{range $index, $element := .Methods}}
func (s *{{$.Name}}) {{$index}}({{$element.Params | joinParamsWithType}}) {{$element.Results | joinResultsForSignature}} {
{{if $element.Results | len | eq 0}}s.Store.{{$index}}({{$element.Params | joinParams}})
{{else}}return s.Store.{{$index}}({{$element.Params | joinParams}})
{{end}}}
{{end}}
func New(childStore store.Store, ctx context.Context) *{{.Name}} {
newStore := {{.Name}}{
Store: childStore,
}
{{range $substoreName, $substore := .SubStores}}
newStore.{{$substoreName}}Store = &{{$.Name}}{{$substoreName}}Store{{"{"}}{{$substoreName}}Store: childStore.{{$substoreName}}(), Root: &newStore}{{end}}
return &newStore
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@@ -373,7 +373,6 @@ type PostStore interface {
PermanentDeleteByChannel(rctx request.CTX, channelID string) error
GetPosts(options model.GetPostsOptions, allowFromCache bool, sanitizeOptions map[string]bool) (*model.PostList, error)
GetFlaggedPosts(userID string, offset int, limit int) (*model.PostList, error)
// @openTracingParams userID, teamID, offset, limit
GetFlaggedPostsForTeam(userID, teamID string, offset int, limit int) (*model.PostList, error)
GetFlaggedPostsForChannel(userID, channelID string, offset int, limit int) (*model.PostList, error)
GetPostsBefore(options model.GetPostsOptions, sanitizeOptions map[string]bool) (*model.PostList, error)

Просмотреть файл

@@ -19,7 +19,7 @@ import (
)
type Context struct {
App app.AppIface
App *app.App
AppContext request.CTX
Logger *mlog.Logger
Params *Params

Просмотреть файл

@@ -16,19 +16,13 @@ import (
"time"
"github.com/klauspost/compress/gzhttp"
"github.com/opentracing/opentracing-go"
"github.com/opentracing/opentracing-go/ext"
spanlog "github.com/opentracing/opentracing-go/log"
"github.com/mattermost/mattermost/server/public/model"
"github.com/mattermost/mattermost/server/public/shared/i18n"
"github.com/mattermost/mattermost/server/public/shared/mlog"
"github.com/mattermost/mattermost/server/public/shared/request"
"github.com/mattermost/mattermost/server/v8/channels/app"
app_opentracing "github.com/mattermost/mattermost/server/v8/channels/app/opentracing"
"github.com/mattermost/mattermost/server/v8/channels/store/opentracinglayer"
"github.com/mattermost/mattermost/server/v8/channels/utils"
"github.com/mattermost/mattermost/server/v8/platform/services/tracing"
)
const (
@@ -210,32 +204,6 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
if *c.App.Config().ServiceSettings.EnableOpenTracing {
span, ctx := tracing.StartRootSpanByContext(context.Background(), "web:ServeHTTP")
carrier := opentracing.HTTPHeadersCarrier(r.Header)
_ = opentracing.GlobalTracer().Inject(span.Context(), opentracing.HTTPHeaders, carrier)
ext.HTTPMethod.Set(span, r.Method)
ext.HTTPUrl.Set(span, c.AppContext.Path())
ext.PeerAddress.Set(span, c.AppContext.IPAddress())
span.SetTag("request_id", c.AppContext.RequestId())
span.SetTag("user_agent", c.AppContext.UserAgent())
defer func() {
if c.Err != nil {
span.LogFields(spanlog.Error(c.Err))
ext.HTTPStatusCode.Set(span, uint16(c.Err.StatusCode))
ext.Error.Set(span, true)
}
span.Finish()
}()
c.AppContext = c.AppContext.WithContext(ctx)
tmpSrv := *c.App.Srv()
tmpSrv.SetStore(opentracinglayer.New(c.App.Srv().Store(), ctx))
c.App.SetServer(&tmpSrv)
c.App = app_opentracing.NewOpenTracingAppLayer(c.App, ctx)
}
var maxBytes int64
if h.FileAPI {
// We add a buffer of bytes.MinRead so that file sizes close to max file size

Просмотреть файл

@@ -57,7 +57,7 @@ func CheckClientCompatibility(agentString string) bool {
return true
}
func Handle404(a app.AppIface, w http.ResponseWriter, r *http.Request) {
func Handle404(a *app.App, w http.ResponseWriter, r *http.Request) {
err := model.NewAppError("Handle404", "api.context.404.app_error", nil, "", http.StatusNotFound)
ipAddress := utils.GetIPAddress(r, a.Config().ServiceSettings.TrustedProxyIPHeader)
mlog.Debug("not found handler triggered", mlog.String("path", r.URL.Path), mlog.Int("code", 404), mlog.String("ip", ipAddress))
@@ -75,19 +75,19 @@ func Handle404(a app.AppIface, w http.ResponseWriter, r *http.Request) {
}
}
func IsAPICall(a app.AppIface, r *http.Request) bool {
func IsAPICall(a *app.App, r *http.Request) bool {
subpath, _ := utils.GetSubpathFromConfig(a.Config())
return strings.HasPrefix(r.URL.Path, path.Join(subpath, "api")+"/")
}
func IsWebhookCall(a app.AppIface, r *http.Request) bool {
func IsWebhookCall(a *app.App, r *http.Request) bool {
subpath, _ := utils.GetSubpathFromConfig(a.Config())
return strings.HasPrefix(r.URL.Path, path.Join(subpath, "hooks")+"/")
}
func IsOAuthAPICall(a app.AppIface, r *http.Request) bool {
func IsOAuthAPICall(a *app.App, r *http.Request) bool {
subpath, _ := utils.GetSubpathFromConfig(a.Config())
if r.Method == "POST" && r.URL.Path == path.Join(subpath, "oauth", "authorize") {

Просмотреть файл

@@ -31,7 +31,7 @@ var apiClient *model.Client4
var URL string
type TestHelper struct {
App app.AppIface
App *app.App
Context request.CTX
Server *app.Server
Web *Web