diff --git a/internal/prometheus/metrics.go b/internal/prometheus/metrics.go index e00738e..141a0f1 100644 --- a/internal/prometheus/metrics.go +++ b/internal/prometheus/metrics.go @@ -108,7 +108,7 @@ func InitMetrics() { // UpdateMetrics updates all metrics with current values func UpdateMetrics() { - info := stats.Load() + info := stats.Load(false) totalMessages.Set(float64(info.Messages)) unreadMessages.Set(float64(info.Unread)) diff --git a/internal/stats/stats.go b/internal/stats/stats.go index 339f432..0869e64 100644 --- a/internal/stats/stats.go +++ b/internal/stats/stats.go @@ -81,7 +81,7 @@ func getBackoff(errCount int) time.Duration { } // Load the current statistics -func Load() AppInformation { +func Load(detectLatestVersion bool) AppInformation { info := AppInformation{} info.Version = config.Version @@ -98,7 +98,7 @@ func Load() AppInformation { if config.DisableVersionCheck { info.LatestVersion = "disabled" - } else { + } else if detectLatestVersion { mu.RLock() cacheValid := time.Now().Before(vCache.expiry) cacheValue := vCache.value diff --git a/server/apiv1/application.go b/server/apiv1/application.go index e7da7c1..11b05d4 100644 --- a/server/apiv1/application.go +++ b/server/apiv1/application.go @@ -28,7 +28,7 @@ func AppInfo(w http.ResponseWriter, _ *http.Request) { // 400: ErrorResponse w.Header().Add("Content-Type", "application/json") - if err := json.NewEncoder(w).Encode(stats.Load()); err != nil { + if err := json.NewEncoder(w).Encode(stats.Load(true)); err != nil { httpError(w, err.Error()) } }