MM-21898: Part 2. Add opentracing (#13904)
* initial implementation of opentracing * app layer * Revert Makefile * . * cleanup * . * . * . * . * . * . * . * . * . * . * . * [ci] * autogenerate interface * . * missed vendor files * updated interfaces * updated store layers * lint fixes * . * finishing layer generators and nested spans * added errors and b3 support * code review * . * . * fixed build error due to misplased flag.Parse() * code review addressed
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
5a34ec4793
Коммит
182c29b456
78
store/layer_generators/timer_layer.go.tmpl
Обычный файл
78
store/layer_generators/timer_layer.go.tmpl
Обычный файл
@@ -0,0 +1,78 @@
|
||||
// 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 store
|
||||
|
||||
import (
|
||||
"context"
|
||||
timemodule "time"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/einterfaces"
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
)
|
||||
|
||||
type {{.Name}} struct {
|
||||
Store
|
||||
Metrics einterfaces.MetricsInterface
|
||||
{{range $index, $element := .SubStores}} {{$index}}Store {{$index}}Store
|
||||
{{end}}
|
||||
}
|
||||
|
||||
{{range $index, $element := .SubStores}}func (s *{{$.Name}}) {{$index}}() {{$index}}Store {
|
||||
return s.{{$index}}Store
|
||||
}
|
||||
|
||||
{{end}}
|
||||
|
||||
{{range $index, $element := .SubStores}}type {{$.Name}}{{$index}}Store struct {
|
||||
{{$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}} {
|
||||
start := timemodule.Now()
|
||||
{{if $element.Results | len | eq 0}}
|
||||
s.{{$substoreName}}Store.{{$index}}({{$element.Params | joinParams}})
|
||||
{{else}}
|
||||
{{$element.Results | genResultsVars}} := s.{{$substoreName}}Store.{{$index}}({{$element.Params | joinParams}})
|
||||
{{end}}
|
||||
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
||||
if s.Root.Metrics != nil {
|
||||
success := "false"
|
||||
if {{$element.Results | errorToBoolean}} {
|
||||
success = "true"
|
||||
}
|
||||
s.Root.Metrics.ObserveStoreMethodDuration("{{$substoreName}}Store.{{$index}}", success, elapsed)
|
||||
{{ with ($element.Results | genResultsVars) -}}
|
||||
}
|
||||
return {{ . }}
|
||||
{{- else -}}
|
||||
}
|
||||
{{- 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{{.Name}}(childStore Store, metrics einterfaces.MetricsInterface) *{{.Name}} {
|
||||
newStore := {{.Name}}{
|
||||
Store: childStore,
|
||||
Metrics: metrics,
|
||||
}
|
||||
{{range $substoreName, $substore := .SubStores}}
|
||||
newStore.{{$substoreName}}Store = &{{$.Name}}{{$substoreName}}Store{{"{"}}{{$substoreName}}Store: childStore.{{$substoreName}}(), Root: &newStore}{{end}}
|
||||
return &newStore
|
||||
}
|
||||
Ссылка в новой задаче
Block a user