Files
team/server/channels/app/layer_generators/opentracing_layer.go.tmpl
fff6089a82 MM 65084 server-side (#33861) (#34006) (#34045)
* MM 65084 server-side (#33861) (#34006)

Automatic Merge

* Add missing changes for API layer

(Run `make app-layers` from server directory before finalizing Cherry pick in the future)

* Fix opentraceing issues.

* More missing channels/store files from not running make store-layers

* Update the opentracing_layer.go.tmpl file to import correct paths.

There is an issue where, at least up until 10.5, we had a `make app-layers` command that gets run on CI in the PR, this uses this go.tmpl file to create api_iface.go (and possibly others). If this file doesn't match what has been committed, it errors out. As the .tmpl file has these missing imports, it generates bad paths, which then cause other errors. So I need to fix the .tmpl file as well.

* Missing model import

* Using correct path for i18n in opentracing_layer

---------

Co-authored-by: Mattermost Build <[email protected]>
2025-10-06 14:02:34 -07:00

168 lines
5.2 KiB
Cheetah

// 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 (
"context"
"io"
"net/http"
"net/url"
"reflect"
"time"
"github.com/mattermost/mattermost/server/public/shared/i18n"
"github.com/mattermost/mattermost/server/public/model"
"github.com/mattermost/mattermost/server/public/plugin"
"github.com/mattermost/mattermost/server/public/shared/httpservice"
"github.com/mattermost/mattermost/server/public/shared/mlog"
"github.com/mattermost/mattermost/server/public/shared/request"
"github.com/mattermost/mattermost/server/public/shared/timezones"
"github.com/mattermost/mattermost/server/v8/channels/app"
"github.com/mattermost/mattermost/server/v8/channels/app/platform"
"github.com/mattermost/mattermost/server/v8/channels/audit"
"github.com/mattermost/mattermost/server/v8/channels/store"
"github.com/mattermost/mattermost/server/v8/einterfaces"
"github.com/mattermost/mattermost/server/v8/platform/services/imageproxy"
"github.com/mattermost/mattermost/server/v8/platform/services/remotecluster"
"github.com/mattermost/mattermost/server/v8/platform/services/searchengine"
"github.com/mattermost/mattermost/server/v8/platform/shared/filestore"
"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
}