From 2a7aa33a0adced764c64a7442b91267a0c4f4d82 Mon Sep 17 00:00:00 2001 From: Ralph Slooten Date: Fri, 25 Jul 2025 19:28:40 +1200 Subject: [PATCH] Fix: Do not check latest release for Prometheus statistics (#522) --- internal/prometheus/metrics.go | 2 +- internal/stats/stats.go | 4 ++-- server/apiv1/application.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) 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()) } }