1
0
mirror of https://github.com/axllent/mailpit.git synced 2025-08-13 20:04:49 +02:00

Fix: Do not check latest release for Prometheus statistics (#522)

This commit is contained in:
Ralph Slooten
2025-07-25 19:28:40 +12:00
parent 45f07d3c9b
commit 2a7aa33a0a
3 changed files with 4 additions and 4 deletions

View File

@@ -108,7 +108,7 @@ func InitMetrics() {
// UpdateMetrics updates all metrics with current values // UpdateMetrics updates all metrics with current values
func UpdateMetrics() { func UpdateMetrics() {
info := stats.Load() info := stats.Load(false)
totalMessages.Set(float64(info.Messages)) totalMessages.Set(float64(info.Messages))
unreadMessages.Set(float64(info.Unread)) unreadMessages.Set(float64(info.Unread))

View File

@@ -81,7 +81,7 @@ func getBackoff(errCount int) time.Duration {
} }
// Load the current statistics // Load the current statistics
func Load() AppInformation { func Load(detectLatestVersion bool) AppInformation {
info := AppInformation{} info := AppInformation{}
info.Version = config.Version info.Version = config.Version
@@ -98,7 +98,7 @@ func Load() AppInformation {
if config.DisableVersionCheck { if config.DisableVersionCheck {
info.LatestVersion = "disabled" info.LatestVersion = "disabled"
} else { } else if detectLatestVersion {
mu.RLock() mu.RLock()
cacheValid := time.Now().Before(vCache.expiry) cacheValid := time.Now().Before(vCache.expiry)
cacheValue := vCache.value cacheValue := vCache.value

View File

@@ -28,7 +28,7 @@ func AppInfo(w http.ResponseWriter, _ *http.Request) {
// 400: ErrorResponse // 400: ErrorResponse
w.Header().Add("Content-Type", "application/json") 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()) httpError(w, err.Error())
} }
} }