MM-43082: Added new telemetry values for groups. (#19918)
Этот коммит содержится в:
@@ -1106,6 +1106,16 @@ func (ts *TelemetryService) trackGroups() {
|
|||||||
mlog.Debug("Could not get group_count", mlog.Err(err))
|
mlog.Debug("Could not get group_count", mlog.Err(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ldapGroupCount, err := ts.dbStore.Group().GroupCountBySource(model.GroupSourceLdap)
|
||||||
|
if err != nil {
|
||||||
|
mlog.Debug("Could not get group_count", mlog.Err(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
customGroupCount, err := ts.dbStore.Group().GroupCountBySource(model.GroupSourceCustom)
|
||||||
|
if err != nil {
|
||||||
|
mlog.Debug("Could not get group_count", mlog.Err(err))
|
||||||
|
}
|
||||||
|
|
||||||
groupTeamCount, err := ts.dbStore.Group().GroupTeamCount()
|
groupTeamCount, err := ts.dbStore.Group().GroupTeamCount()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
mlog.Debug("Could not get group_team_count", mlog.Err(err))
|
mlog.Debug("Could not get group_team_count", mlog.Err(err))
|
||||||
@@ -1143,6 +1153,8 @@ func (ts *TelemetryService) trackGroups() {
|
|||||||
|
|
||||||
ts.SendTelemetry(TrackGroups, map[string]interface{}{
|
ts.SendTelemetry(TrackGroups, map[string]interface{}{
|
||||||
"group_count": groupCount,
|
"group_count": groupCount,
|
||||||
|
"ldap_group_count": ldapGroupCount,
|
||||||
|
"custom_group_count": customGroupCount,
|
||||||
"group_team_count": groupTeamCount,
|
"group_team_count": groupTeamCount,
|
||||||
"group_channel_count": groupChannelCount,
|
"group_channel_count": groupChannelCount,
|
||||||
"group_synced_team_count": groupSyncedTeamCount,
|
"group_synced_team_count": groupSyncedTeamCount,
|
||||||
|
|||||||
@@ -130,6 +130,8 @@ func initializeMocks(cfg *model.Config) (*mocks.ServerIface, *storeMocks.Store,
|
|||||||
groupStore.On("GroupMemberCount").Return(int64(32), nil)
|
groupStore.On("GroupMemberCount").Return(int64(32), nil)
|
||||||
groupStore.On("DistinctGroupMemberCount").Return(int64(22), nil)
|
groupStore.On("DistinctGroupMemberCount").Return(int64(22), nil)
|
||||||
groupStore.On("GroupCountWithAllowReference").Return(int64(13), nil)
|
groupStore.On("GroupCountWithAllowReference").Return(int64(13), nil)
|
||||||
|
groupStore.On("GroupCountBySource", model.GroupSourceCustom).Return(int64(10), nil)
|
||||||
|
groupStore.On("GroupCountBySource", model.GroupSourceLdap).Return(int64(2), nil)
|
||||||
|
|
||||||
schemeStore := storeMocks.SchemeStore{}
|
schemeStore := storeMocks.SchemeStore{}
|
||||||
schemeStore.On("CountByScope", "channel").Return(int64(8), nil)
|
schemeStore.On("CountByScope", "channel").Return(int64(8), nil)
|
||||||
|
|||||||
@@ -4213,6 +4213,24 @@ func (s *OpenTracingLayerGroupStore) GroupCount() (int64, error) {
|
|||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *OpenTracingLayerGroupStore) GroupCountBySource(source model.GroupSource) (int64, error) {
|
||||||
|
origCtx := s.Root.Store.Context()
|
||||||
|
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "GroupStore.GroupCountBySource")
|
||||||
|
s.Root.Store.SetContext(newCtx)
|
||||||
|
defer func() {
|
||||||
|
s.Root.Store.SetContext(origCtx)
|
||||||
|
}()
|
||||||
|
|
||||||
|
defer span.Finish()
|
||||||
|
result, err := s.GroupStore.GroupCountBySource(source)
|
||||||
|
if err != nil {
|
||||||
|
span.LogFields(spanlog.Error(err))
|
||||||
|
ext.Error.Set(span, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, err
|
||||||
|
}
|
||||||
|
|
||||||
func (s *OpenTracingLayerGroupStore) GroupCountWithAllowReference() (int64, error) {
|
func (s *OpenTracingLayerGroupStore) GroupCountWithAllowReference() (int64, error) {
|
||||||
origCtx := s.Root.Store.Context()
|
origCtx := s.Root.Store.Context()
|
||||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "GroupStore.GroupCountWithAllowReference")
|
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "GroupStore.GroupCountWithAllowReference")
|
||||||
|
|||||||
@@ -4750,6 +4750,27 @@ func (s *RetryLayerGroupStore) GroupCount() (int64, error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *RetryLayerGroupStore) GroupCountBySource(source model.GroupSource) (int64, error) {
|
||||||
|
|
||||||
|
tries := 0
|
||||||
|
for {
|
||||||
|
result, err := s.GroupStore.GroupCountBySource(source)
|
||||||
|
if err == nil {
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
if !isRepeatableError(err) {
|
||||||
|
return result, err
|
||||||
|
}
|
||||||
|
tries++
|
||||||
|
if tries >= 3 {
|
||||||
|
err = errors.Wrap(err, "giving up after 3 consecutive repeatable transaction failures")
|
||||||
|
return result, err
|
||||||
|
}
|
||||||
|
timepkg.Sleep(100 * timepkg.Millisecond)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func (s *RetryLayerGroupStore) GroupCountWithAllowReference() (int64, error) {
|
func (s *RetryLayerGroupStore) GroupCountWithAllowReference() (int64, error) {
|
||||||
|
|
||||||
tries := 0
|
tries := 0
|
||||||
|
|||||||
@@ -1720,6 +1720,10 @@ func (s *SqlGroupStore) GroupCount() (int64, error) {
|
|||||||
return s.countTable("UserGroups")
|
return s.countTable("UserGroups")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *SqlGroupStore) GroupCountBySource(source model.GroupSource) (int64, error) {
|
||||||
|
return s.countTableWithSelectAndWhere("COUNT(*)", "UserGroups", sq.Eq{"Source": source, "DeleteAt": 0})
|
||||||
|
}
|
||||||
|
|
||||||
func (s *SqlGroupStore) GroupTeamCount() (int64, error) {
|
func (s *SqlGroupStore) GroupTeamCount() (int64, error) {
|
||||||
return s.countTable("GroupTeams")
|
return s.countTable("GroupTeams")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -853,6 +853,8 @@ type GroupStore interface {
|
|||||||
// GroupCount returns the total count of records in the UserGroups table.
|
// GroupCount returns the total count of records in the UserGroups table.
|
||||||
GroupCount() (int64, error)
|
GroupCount() (int64, error)
|
||||||
|
|
||||||
|
GroupCountBySource(source model.GroupSource) (int64, error)
|
||||||
|
|
||||||
// GroupTeamCount returns the total count of records in the GroupTeams table.
|
// GroupTeamCount returns the total count of records in the GroupTeams table.
|
||||||
GroupTeamCount() (int64, error)
|
GroupTeamCount() (int64, error)
|
||||||
|
|
||||||
|
|||||||
@@ -849,6 +849,27 @@ func (_m *GroupStore) GroupCount() (int64, error) {
|
|||||||
return r0, r1
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GroupCountBySource provides a mock function with given fields: source
|
||||||
|
func (_m *GroupStore) GroupCountBySource(source model.GroupSource) (int64, error) {
|
||||||
|
ret := _m.Called(source)
|
||||||
|
|
||||||
|
var r0 int64
|
||||||
|
if rf, ok := ret.Get(0).(func(model.GroupSource) int64); ok {
|
||||||
|
r0 = rf(source)
|
||||||
|
} else {
|
||||||
|
r0 = ret.Get(0).(int64)
|
||||||
|
}
|
||||||
|
|
||||||
|
var r1 error
|
||||||
|
if rf, ok := ret.Get(1).(func(model.GroupSource) error); ok {
|
||||||
|
r1 = rf(source)
|
||||||
|
} else {
|
||||||
|
r1 = ret.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0, r1
|
||||||
|
}
|
||||||
|
|
||||||
// GroupCountWithAllowReference provides a mock function with given fields:
|
// GroupCountWithAllowReference provides a mock function with given fields:
|
||||||
func (_m *GroupStore) GroupCountWithAllowReference() (int64, error) {
|
func (_m *GroupStore) GroupCountWithAllowReference() (int64, error) {
|
||||||
ret := _m.Called()
|
ret := _m.Called()
|
||||||
|
|||||||
@@ -3835,6 +3835,22 @@ func (s *TimerLayerGroupStore) GroupCount() (int64, error) {
|
|||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *TimerLayerGroupStore) GroupCountBySource(source model.GroupSource) (int64, error) {
|
||||||
|
start := timemodule.Now()
|
||||||
|
|
||||||
|
result, err := s.GroupStore.GroupCountBySource(source)
|
||||||
|
|
||||||
|
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
||||||
|
if s.Root.Metrics != nil {
|
||||||
|
success := "false"
|
||||||
|
if err == nil {
|
||||||
|
success = "true"
|
||||||
|
}
|
||||||
|
s.Root.Metrics.ObserveStoreMethodDuration("GroupStore.GroupCountBySource", success, elapsed)
|
||||||
|
}
|
||||||
|
return result, err
|
||||||
|
}
|
||||||
|
|
||||||
func (s *TimerLayerGroupStore) GroupCountWithAllowReference() (int64, error) {
|
func (s *TimerLayerGroupStore) GroupCountWithAllowReference() (int64, error) {
|
||||||
start := timemodule.Now()
|
start := timemodule.Now()
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user