StatsColelctor: Check if result is nil before set the metrics (#59372)

Check if result is nil before set the metrics
This commit is contained in:
Selene 2022-11-28 11:40:49 +01:00 committed by GitHub
parent 64143ea7d0
commit 92e3ee7d89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -321,6 +321,11 @@ func (s *Service) updateTotalStats(ctx context.Context) bool {
return false
}
if statsQuery.Result == nil {
s.log.Error("Cannot retrieve system stats")
return false
}
metrics.MStatTotalDashboards.Set(float64(statsQuery.Result.Dashboards))
metrics.MStatTotalFolders.Set(float64(statsQuery.Result.Folders))
metrics.MStatTotalUsers.Set(float64(statsQuery.Result.Users))