Improves group membership telemetry. (#20437)

* Improves groups membership telemetry.

* Removes unnecessary where clause (it's added by default).

* Cleans up data.

* Testing the relative group counts.

* Adds missing test mock.

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Martin Kraft
2022-06-15 09:42:27 -04:00
коммит произвёл GitHub
родитель 9d0c99068a
Коммит 4e9edef1f1
9 изменённых файлов: 202 добавлений и 10 удалений

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

@@ -1164,22 +1164,34 @@ func (ts *TelemetryService) trackGroups() {
mlog.Debug("Could not get distinct_group_member_count", mlog.Err(err))
}
distinctCustomGroupMemberCount, err := ts.dbStore.Group().DistinctGroupMemberCountForSource(model.GroupSourceCustom)
if err != nil {
mlog.Debug("Could not get distinct_custom_group_member_count", mlog.Err(err))
}
distinctLdapGroupMemberCount, err := ts.dbStore.Group().DistinctGroupMemberCountForSource(model.GroupSourceLdap)
if err != nil {
mlog.Debug("Could not get distinct_ldap_group_member_count", mlog.Err(err))
}
groupCountWithAllowReference, err := ts.dbStore.Group().GroupCountWithAllowReference()
if err != nil {
mlog.Debug("Could not get group_count_with_allow_reference", mlog.Err(err))
}
ts.SendTelemetry(TrackGroups, map[string]interface{}{
"group_count": groupCount,
"ldap_group_count": ldapGroupCount,
"custom_group_count": customGroupCount,
"group_team_count": groupTeamCount,
"group_channel_count": groupChannelCount,
"group_synced_team_count": groupSyncedTeamCount,
"group_synced_channel_count": groupSyncedChannelCount,
"group_member_count": groupMemberCount,
"distinct_group_member_count": distinctGroupMemberCount,
"group_count_with_allow_reference": groupCountWithAllowReference,
"group_count": groupCount,
"ldap_group_count": ldapGroupCount,
"custom_group_count": customGroupCount,
"group_team_count": groupTeamCount,
"group_channel_count": groupChannelCount,
"group_synced_team_count": groupSyncedTeamCount,
"group_synced_channel_count": groupSyncedChannelCount,
"group_member_count": groupMemberCount,
"distinct_group_member_count": distinctGroupMemberCount,
"distinct_custom_group_member_count": distinctCustomGroupMemberCount,
"distinct_ldap_group_member_count": distinctLdapGroupMemberCount,
"group_count_with_allow_reference": groupCountWithAllowReference,
})
}

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

@@ -242,6 +242,7 @@ func initializeMocks(cfg *model.Config, cloudLicense bool) (*mocks.ServerIface,
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)
groupStore.On("DistinctGroupMemberCountForSource", mock.AnythingOfType("model.GroupSource")).Return(int64(1), nil)
schemeStore := storeMocks.SchemeStore{}
schemeStore.On("CountByScope", "channel").Return(int64(8), nil)