Skip to content

Commit

Permalink
Fix: Rename metrics to use unix timestamps
Browse files Browse the repository at this point in the history
Changed the metrics for last reload and application start to report Unix timestamps instead of seconds since the events. This provides precise timestamps for better tracking and analysis.

Signed-off-by: Christian Roessner <c@roessner.co>
  • Loading branch information
Christian Roessner committed Sep 30, 2024
1 parent 7d3e77f commit f0c14e6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions server/stats/statistics.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,27 @@ func init() {
// Create the metric for the time since last reload
promauto.NewGaugeFunc(
prometheus.GaugeOpts{
Name: "nauthilus_seconds_since_last_reload",
Help: "Number of seconds since the application was last reloaded",
Name: "nauthilus_last_reload_timestamp",
Help: "Unix timestamp of the last reload",
},
func() float64 {
ReloadMutex.RLock()

defer ReloadMutex.RUnlock()

return time.Since(LastReloadTime).Seconds()
return float64(LastReloadTime.Unix())
},
)

startTime := time.Now()

promauto.NewGaugeFunc(
prometheus.GaugeOpts{
Name: "nauthilus_seconds_since_start",
Help: "Number of seconds since the application has started",
Name: "nauthilus_start_timestamp",
Help: "Unix timestamp of the application start",
},
func() float64 {
return time.Since(startTime).Seconds()
return float64(startTime.Unix())
},
)
}
Expand Down

0 comments on commit f0c14e6

Please sign in to comment.