mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Metrics: Adds setting for turning off total stats metrics (#19142)
Don't update total stats metrics if reporting is disabled. New setting disable_total_stats for turning off update of total stats (stat_totals_*) metrics. Ref #19137
This commit is contained in:
committed by
GitHub
parent
bf40849a2c
commit
80592e3361
@@ -264,6 +264,49 @@ func TestMetrics(t *testing.T) {
|
||||
ts.Close()
|
||||
})
|
||||
})
|
||||
|
||||
Convey("Test update total stats", t, func() {
|
||||
uss := &UsageStatsService{
|
||||
Bus: bus.New(),
|
||||
Cfg: setting.NewCfg(),
|
||||
}
|
||||
uss.Cfg.MetricsEndpointEnabled = true
|
||||
uss.Cfg.MetricsEndpointDisableTotalStats = false
|
||||
getSystemStatsWasCalled := false
|
||||
uss.Bus.AddHandler(func(query *models.GetSystemStatsQuery) error {
|
||||
query.Result = &models.SystemStats{}
|
||||
getSystemStatsWasCalled = true
|
||||
return nil
|
||||
})
|
||||
|
||||
Convey("should not update stats when metrics is disabled and total stats is disabled", func() {
|
||||
uss.Cfg.MetricsEndpointEnabled = false
|
||||
uss.Cfg.MetricsEndpointDisableTotalStats = true
|
||||
uss.updateTotalStats()
|
||||
So(getSystemStatsWasCalled, ShouldBeFalse)
|
||||
})
|
||||
|
||||
Convey("should not update stats when metrics is disabled and total stats enabled", func() {
|
||||
uss.Cfg.MetricsEndpointEnabled = false
|
||||
uss.Cfg.MetricsEndpointDisableTotalStats = false
|
||||
uss.updateTotalStats()
|
||||
So(getSystemStatsWasCalled, ShouldBeFalse)
|
||||
})
|
||||
|
||||
Convey("should not update stats when metrics is enabled and total stats disabled", func() {
|
||||
uss.Cfg.MetricsEndpointEnabled = true
|
||||
uss.Cfg.MetricsEndpointDisableTotalStats = true
|
||||
uss.updateTotalStats()
|
||||
So(getSystemStatsWasCalled, ShouldBeFalse)
|
||||
})
|
||||
|
||||
Convey("should update stats when metrics is enabled and total stats enabled", func() {
|
||||
uss.Cfg.MetricsEndpointEnabled = true
|
||||
uss.Cfg.MetricsEndpointDisableTotalStats = false
|
||||
uss.updateTotalStats()
|
||||
So(getSystemStatsWasCalled, ShouldBeTrue)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func waitTimeout(wg *sync.WaitGroup, timeout time.Duration) bool {
|
||||
|
||||
Reference in New Issue
Block a user