Chore: Add stat for remote cache config (#64276)

* add stat for remote cache config
pull/64325/head
Dan Cech 2 years ago committed by GitHub
parent 20b79b41eb
commit 9276f11388
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      pkg/infra/usagestats/statscollector/service.go
  2. 4
      pkg/infra/usagestats/statscollector/service_test.go

@ -173,6 +173,9 @@ func (s *Service) collectSystemStats(ctx context.Context) (map[string]interface{
}
m["stats.avg_auth_token_per_user.count"] = avgAuthTokensPerUser
if s.cfg.RemoteCacheOptions != nil && s.cfg.RemoteCacheOptions.Name != "" {
m["stats.remote_cache."+s.cfg.RemoteCacheOptions.Name+".count"] = 1
}
m["stats.packaging."+s.cfg.Packaging+".count"] = 1
m["stats.distributor."+s.cfg.ReportingDistributor+".count"] = 1

@ -152,6 +152,9 @@ func TestCollectingUsageStats(t *testing.T) {
AuthProxyEnabled: true,
Packaging: "deb",
ReportingDistributor: "hosted-grafana",
RemoteCacheOptions: &setting.RemoteCacheOptions{
Name: "database",
},
}, sqlStore, statsService,
withDatasources(mockDatasourceService{datasources: expectedDataSources}))
@ -179,6 +182,7 @@ func TestCollectingUsageStats(t *testing.T) {
assert.EqualValues(t, 11, metrics["stats.data_keys.count"])
assert.EqualValues(t, 3, metrics["stats.active_data_keys.count"])
assert.EqualValues(t, 5, metrics["stats.public_dashboards.count"])
assert.EqualValues(t, 1, metrics["stats.remote_cache.database.count"])
assert.InDelta(t, int64(65), metrics["stats.uptime"], 6)
}

Loading…
Cancel
Save