Chore: Fix grafana live stats reset when sending usage stats (#39558)
This commit is contained in:
@@ -71,6 +71,8 @@ func (usm *usageStatsMock) ShouldBeReported(_ string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (usm *usageStatsMock) RegisterSendReportCallback(_ usagestats.SendReportCallbackFunc) {}
|
||||
|
||||
type evaluatingPermissionsTestCase struct {
|
||||
desc string
|
||||
user userTestCase
|
||||
|
||||
@@ -67,6 +67,8 @@ func (usm *usageStatsMock) ShouldBeReported(_ string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (usm *usageStatsMock) RegisterSendReportCallback(_ usagestats.SendReportCallbackFunc) {}
|
||||
|
||||
func TestEngineProcessJob(t *testing.T) {
|
||||
Convey("Alerting engine job processing", t, func() {
|
||||
bus := bus.New()
|
||||
|
||||
@@ -1031,7 +1031,13 @@ func (g *GrafanaLive) sampleLiveStats() {
|
||||
}
|
||||
}
|
||||
|
||||
func (g *GrafanaLive) resetLiveStats() {
|
||||
g.usageStats = usageStats{}
|
||||
}
|
||||
|
||||
func (g *GrafanaLive) registerUsageMetrics() {
|
||||
g.usageStatsService.RegisterSendReportCallback(g.resetLiveStats)
|
||||
|
||||
g.usageStatsService.RegisterMetricsFunc(func() (map[string]interface{}, error) {
|
||||
liveUsersAvg := 0
|
||||
liveClientsAvg := 0
|
||||
@@ -1051,8 +1057,6 @@ func (g *GrafanaLive) registerUsageMetrics() {
|
||||
"stats.live_clients_avg.count": liveClientsAvg,
|
||||
}
|
||||
|
||||
g.usageStats = usageStats{}
|
||||
|
||||
return metrics, nil
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user