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
Этот коммит содержится в:
Miguel de la Cruz
2020-03-05 14:46:08 +01:00
коммит произвёл GitHub
родитель 5a34ec4793
Коммит 182c29b456
154 изменённых файлов: 47653 добавлений и 264 удалений

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

@@ -11,62 +11,135 @@ import (
"go/parser"
"go/token"
"io/ioutil"
"log"
"os"
"path"
"strings"
"text/template"
)
const OPEN_TRACING_PARAMS_MARKER = "@openTracingParams"
func main() {
code := GenerateTimerLayer()
formatedCode, err := format.Source([]byte(code))
if err != nil {
panic(err)
if err := buildTimerLayer(); err != nil {
log.Fatal(err)
}
err = ioutil.WriteFile(path.Join("timer_layer.go"), formatedCode, 0644)
if err != nil {
panic(err)
if err := buildOpenTracingLayer(); err != nil {
log.Fatal(err)
}
}
type Param struct {
func buildTimerLayer() error {
code, err := generateLayer("TimerLayer", "timer_layer.go.tmpl")
if err != nil {
return err
}
formatedCode, err := format.Source(code)
if err != nil {
return err
}
return ioutil.WriteFile(path.Join("timer_layer.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 ioutil.WriteFile(path.Join("opentracing_layer.go"), formatedCode, 0644)
}
type methodParam struct {
Name string
Type string
}
type Method struct {
Params []Param
Results []string
type methodData struct {
Params []methodParam
Results []string
ParamsToTrace map[string]bool
}
type SubStore struct {
Methods map[string]Method
type subStore struct {
Methods map[string]methodData
}
type StoreMetadata struct {
type storeMetadata struct {
Name string
SubStores map[string]SubStore
Methods map[string]Method
SubStores map[string]subStore
Methods map[string]methodData
}
func ExtractStoreMetadata() StoreMetadata {
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, OPEN_TRACING_PARAMS_MARKER); idx != -1 {
for _, p := range strings.Split(s[idx+len(OPEN_TRACING_PARAMS_MARKER):], ",") {
paramsToTrace[strings.TrimSpace(p)] = true
}
}
}
}
if e.Params != nil {
for _, param := range e.Params.List {
for _, paramName := range param.Names {
params = append(params, methodParam{Name: paramName.Name, Type: string(src[param.Type.Pos()-1 : param.Type.End()-1])})
}
}
}
if e.Results != nil {
for _, result := range e.Results.List {
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, OPEN_TRACING_PARAMS_MARKER)
}
}
}
return true
})
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("store.go")
if err != nil {
panic("Unable to open store/store.go file")
return nil, fmt.Errorf("Unable to open store/store.go file: %w", err)
}
src, err := ioutil.ReadAll(file)
if err != nil {
panic(err)
return nil, err
}
file.Close()
f, err := parser.ParseFile(fset, "", src, 0)
f, err := parser.ParseFile(fset, "", src, parser.AllErrors|parser.ParseComments)
if err != nil {
panic(err)
return nil, err
}
topLevelFunctions := map[string]bool{
@@ -77,11 +150,12 @@ func ExtractStoreMetadata() StoreMetadata {
"DropAllTables": false,
"TotalMasterDbConnections": true,
"TotalReadDbConnections": true,
"SetContext": true,
"TotalSearchDbConnections": true,
"GetCurrentSchemaVersion": true,
}
metadata := StoreMetadata{Methods: map[string]Method{}, SubStores: map[string]SubStore{}}
metadata := storeMetadata{Methods: map[string]methodData{}, SubStores: map[string]subStore{}}
ast.Inspect(f, func(n ast.Node) bool {
switch x := n.(type) {
@@ -90,72 +164,31 @@ func ExtractStoreMetadata() StoreMetadata {
for _, method := range x.Type.(*ast.InterfaceType).Methods.List {
methodName := method.Names[0].Name
if _, ok := topLevelFunctions[methodName]; ok {
params := []Param{}
results := []string{}
ast.Inspect(method.Type, func(expr ast.Node) bool {
switch e := expr.(type) {
case *ast.FuncType:
if e.Params != nil {
for _, param := range e.Params.List {
for _, paramName := range param.Names {
params = append(params, Param{Name: paramName.Name, Type: string(src[param.Type.Pos()-1 : param.Type.End()-1])})
}
}
}
if e.Results != nil {
for _, result := range e.Results.List {
results = append(results, string(src[result.Type.Pos()-1:result.Type.End()-1]))
}
}
}
return true
})
metadata.Methods[methodName] = Method{Params: params, Results: results}
metadata.Methods[methodName] = extractMethodMetadata(method, src)
}
}
} else if strings.HasSuffix(x.Name.Name, "Store") {
subStoreName := strings.TrimSuffix(x.Name.Name, "Store")
metadata.SubStores[subStoreName] = SubStore{Methods: map[string]Method{}}
metadata.SubStores[subStoreName] = subStore{Methods: map[string]methodData{}}
for _, method := range x.Type.(*ast.InterfaceType).Methods.List {
methodName := method.Names[0].Name
params := []Param{}
results := []string{}
ast.Inspect(method.Type, func(expr ast.Node) bool {
switch e := expr.(type) {
case *ast.FuncType:
if e.Params != nil {
for _, param := range e.Params.List {
for _, paramName := range param.Names {
params = append(params, Param{Name: paramName.Name, Type: string(src[param.Type.Pos()-1 : param.Type.End()-1])})
}
}
}
if e.Results != nil {
for _, result := range e.Results.List {
results = append(results, string(src[result.Type.Pos()-1:result.Type.End()-1]))
}
}
}
return true
})
metadata.SubStores[subStoreName].Methods[methodName] = Method{Params: params, Results: results}
metadata.SubStores[subStoreName].Methods[methodName] = extractMethodMetadata(method, src)
}
}
}
return true
})
return metadata
return &metadata, nil
}
func GenerateTimerLayer() string {
func generateLayer(name, templateFile string) ([]byte, error) {
out := bytes.NewBufferString("")
metadata := ExtractStoreMetadata()
metadata.Name = "TimerLayer"
metadata, err := extractStoreMetadata()
if err != nil {
return nil, err
}
metadata.Name = name
myFuncs := template.FuncMap{
"joinResults": func(results []string) string {
@@ -172,27 +205,43 @@ func GenerateTimerLayer() string {
},
"genResultsVars": func(results []string) string {
vars := []string{}
for idx := range results {
vars = append(vars, fmt.Sprintf("resultVar%d", idx))
for i := range results {
vars = append(vars, fmt.Sprintf("resultVar%d", i))
}
return strings.Join(vars, ", ")
},
"errorToBoolean": func(results []string) string {
for idx, typeName := range results {
for i, typeName := range results {
if typeName == "*model.AppError" {
return fmt.Sprintf("resultVar%d == nil", idx)
return fmt.Sprintf("resultVar%d == nil", i)
}
}
return "true"
},
"joinParams": func(params []Param) string {
paramsNames := []string{}
"errorPresent": func(results []string) bool {
for _, typeName := range results {
if typeName == "*model.AppError" {
return true
}
}
return false
},
"errorVar": func(results []string) string {
for i, typeName := range results {
if typeName == "*model.AppError" {
return fmt.Sprintf("resultVar%d", i)
}
}
return ""
},
"joinParams": func(params []methodParam) string {
paramsNames := make([]string, 0, len(params))
for _, param := range params {
paramsNames = append(paramsNames, param.Name)
}
return strings.Join(paramsNames, ", ")
},
"joinParamsWithType": func(params []Param) string {
"joinParamsWithType": func(params []methodParam) string {
paramsWithType := []string{}
for _, param := range params {
paramsWithType = append(paramsWithType, fmt.Sprintf("%s %s", param.Name, param.Type))
@@ -201,91 +250,9 @@ func GenerateTimerLayer() string {
},
}
t, err := template.New("timer-layer").Funcs(myFuncs).Parse(`
// 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 (
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) -}}
t := template.Must(template.New(templateFile).Funcs(myFuncs).ParseFiles("layer_generators/" + templateFile))
if err = t.Execute(out, metadata); err != nil {
return nil, err
}
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
}
`)
if err != nil {
panic(err)
}
err = t.Execute(out, metadata)
if err != nil {
panic(err)
}
return out.String()
return out.Bytes(), nil
}

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

@@ -0,0 +1,82 @@
// 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"
"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/services/tracing"
"github.com/opentracing/opentracing-go/ext"
spanlog "github.com/opentracing/opentracing-go/log"
)
type {{.Name}} struct {
Store
{{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}} {
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}}
{{$element.Results | genResultsVars}} := 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 {{ $element.Results | genResultsVars -}}
{{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, 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
}

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
}

8704
store/opentracing_layer.go Обычный файл

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

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

@@ -111,6 +111,7 @@ type SqlSupplier struct {
stores SqlSupplierStores
settings *model.SqlSettings
lockedToMaster bool
context context.Context
}
type TraceOnAdapter struct{}
@@ -266,6 +267,14 @@ func setupConnection(con_type string, dataSource string, settings *model.SqlSett
return dbmap
}
func (ss *SqlSupplier) SetContext(context context.Context) {
ss.context = context
}
func (ss *SqlSupplier) Context() context.Context {
return ss.context
}
func (ss *SqlSupplier) initConnection() {
ss.master = setupConnection("master", *ss.settings.DataSource, ss.settings)

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

@@ -6,6 +6,8 @@
package store
import (
"context"
"github.com/mattermost/mattermost-server/v5/model"
)
@@ -56,6 +58,8 @@ type Store interface {
TotalReadDbConnections() int
TotalSearchDbConnections() int
CheckIntegrity() <-chan IntegrityCheckResult
SetContext(context context.Context)
Context() context.Context
}
type TeamStore interface {
@@ -223,6 +227,7 @@ type PostStore interface {
PermanentDeleteByChannel(channelId string) *model.AppError
GetPosts(options model.GetPostsOptions, allowFromCache bool) (*model.PostList, *model.AppError)
GetFlaggedPosts(userId string, offset int, limit int) (*model.PostList, *model.AppError)
// @openTracingParams userId, teamId, offset, limit
GetFlaggedPostsForTeam(userId, teamId string, offset int, limit int) (*model.PostList, *model.AppError)
GetFlaggedPostsForChannel(userId, channelId string, offset int, limit int) (*model.PostList, *model.AppError)
GetPostsBefore(options model.GetPostsOptions) (*model.PostList, *model.AppError)

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

@@ -5,6 +5,8 @@
package mocks
import (
context "context"
store "github.com/mattermost/mattermost-server/v5/store"
mock "github.com/stretchr/testify/mock"
)
@@ -163,6 +165,22 @@ func (_m *Store) Compliance() store.ComplianceStore {
return r0
}
// Context provides a mock function with given fields:
func (_m *Store) Context() context.Context {
ret := _m.Called()
var r0 context.Context
if rf, ok := ret.Get(0).(func() context.Context); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(context.Context)
}
}
return r0
}
// DropAllTables provides a mock function with given fields:
func (_m *Store) DropAllTables() {
_m.Called()
@@ -416,6 +434,11 @@ func (_m *Store) Session() store.SessionStore {
return r0
}
// SetContext provides a mock function with given fields: _a0
func (_m *Store) SetContext(_a0 context.Context) {
_m.Called(_a0)
}
// Status provides a mock function with given fields:
func (_m *Store) Status() store.StatusStore {
ret := _m.Called()

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

@@ -4,6 +4,8 @@
package storetest
import (
"context"
"github.com/mattermost/mattermost-server/v5/store"
"github.com/mattermost/mattermost-server/v5/store/storetest/mocks"
"github.com/stretchr/testify/mock"
@@ -42,8 +44,11 @@ type Store struct {
GroupStore mocks.GroupStore
UserTermsOfServiceStore mocks.UserTermsOfServiceStore
LinkMetadataStore mocks.LinkMetadataStore
context context.Context
}
func (s *Store) SetContext(context context.Context) { s.context = context }
func (s *Store) Context() context.Context { return s.context }
func (s *Store) Team() store.TeamStore { return &s.TeamStore }
func (s *Store) Channel() store.ChannelStore { return &s.ChannelStore }
func (s *Store) Post() store.PostStore { return &s.PostStore }

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

@@ -7,6 +7,7 @@
package store
import (
"context"
timemodule "time"
"github.com/mattermost/mattermost-server/v5/einterfaces"
@@ -1207,6 +1208,22 @@ func (s *TimerLayerChannelStore) GetTeamChannels(teamId string) (*model.ChannelL
return resultVar0, resultVar1
}
func (s *TimerLayerChannelStore) GroupSyncedChannelCount() (int64, *model.AppError) {
start := timemodule.Now()
resultVar0, resultVar1 := s.ChannelStore.GroupSyncedChannelCount()
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
if s.Root.Metrics != nil {
success := "false"
if resultVar1 == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GroupSyncedChannelCount", success, elapsed)
}
return resultVar0, resultVar1
}
func (s *TimerLayerChannelStore) IncrementMentionCount(channelId string, userId string) *model.AppError {
start := timemodule.Now()
@@ -2446,6 +2463,22 @@ func (s *TimerLayerFileInfoStore) GetForUser(userId string) ([]*model.FileInfo,
return resultVar0, resultVar1
}
func (s *TimerLayerFileInfoStore) GetWithOptions(page int, perPage int, opt *model.GetFileInfosOptions) ([]*model.FileInfo, *model.AppError) {
start := timemodule.Now()
resultVar0, resultVar1 := s.FileInfoStore.GetWithOptions(page, perPage, opt)
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
if s.Root.Metrics != nil {
success := "false"
if resultVar1 == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("FileInfoStore.GetWithOptions", success, elapsed)
}
return resultVar0, resultVar1
}
func (s *TimerLayerFileInfoStore) InvalidateFileInfosForPostCache(postId string) {
start := timemodule.Now()
@@ -2733,6 +2766,22 @@ func (s *TimerLayerGroupStore) DeleteMember(groupID string, userID string) (*mod
return resultVar0, resultVar1
}
func (s *TimerLayerGroupStore) DistinctGroupMemberCount() (int64, *model.AppError) {
start := timemodule.Now()
resultVar0, resultVar1 := s.GroupStore.DistinctGroupMemberCount()
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
if s.Root.Metrics != nil {
success := "false"
if resultVar1 == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.DistinctGroupMemberCount", success, elapsed)
}
return resultVar0, resultVar1
}
func (s *TimerLayerGroupStore) Get(groupID string) (*model.Group, *model.AppError) {
start := timemodule.Now()
@@ -2957,6 +3006,70 @@ func (s *TimerLayerGroupStore) GetMemberUsersPage(groupID string, page int, perP
return resultVar0, resultVar1
}
func (s *TimerLayerGroupStore) GroupChannelCount() (int64, *model.AppError) {
start := timemodule.Now()
resultVar0, resultVar1 := s.GroupStore.GroupChannelCount()
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
if s.Root.Metrics != nil {
success := "false"
if resultVar1 == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GroupChannelCount", success, elapsed)
}
return resultVar0, resultVar1
}
func (s *TimerLayerGroupStore) GroupCount() (int64, *model.AppError) {
start := timemodule.Now()
resultVar0, resultVar1 := s.GroupStore.GroupCount()
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
if s.Root.Metrics != nil {
success := "false"
if resultVar1 == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GroupCount", success, elapsed)
}
return resultVar0, resultVar1
}
func (s *TimerLayerGroupStore) GroupMemberCount() (int64, *model.AppError) {
start := timemodule.Now()
resultVar0, resultVar1 := s.GroupStore.GroupMemberCount()
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
if s.Root.Metrics != nil {
success := "false"
if resultVar1 == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GroupMemberCount", success, elapsed)
}
return resultVar0, resultVar1
}
func (s *TimerLayerGroupStore) GroupTeamCount() (int64, *model.AppError) {
start := timemodule.Now()
resultVar0, resultVar1 := s.GroupStore.GroupTeamCount()
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
if s.Root.Metrics != nil {
success := "false"
if resultVar1 == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GroupTeamCount", success, elapsed)
}
return resultVar0, resultVar1
}
func (s *TimerLayerGroupStore) PermanentDeleteMembersByUser(userId string) *model.AppError {
start := timemodule.Now()
@@ -5657,6 +5770,22 @@ func (s *TimerLayerTeamStore) GetUserTeamIds(userId string, allowFromCache bool)
return resultVar0, resultVar1
}
func (s *TimerLayerTeamStore) GroupSyncedTeamCount() (int64, *model.AppError) {
start := timemodule.Now()
resultVar0, resultVar1 := s.TeamStore.GroupSyncedTeamCount()
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
if s.Root.Metrics != nil {
success := "false"
if resultVar1 == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("TeamStore.GroupSyncedTeamCount", success, elapsed)
}
return resultVar0, resultVar1
}
func (s *TimerLayerTeamStore) InvalidateAllTeamIdsForUser(userId string) {
start := timemodule.Now()
@@ -7701,6 +7830,10 @@ func (s *TimerLayer) MarkSystemRanUnitTests() {
s.Store.MarkSystemRanUnitTests()
}
func (s *TimerLayer) SetContext(context context.Context) {
s.Store.SetContext(context)
}
func (s *TimerLayer) TotalMasterDbConnections() int {
return s.Store.TotalMasterDbConnections()
}