mirror of
https://github.com/safing/portbase
synced 2025-04-17 16:09:08 +00:00
Report info metric as 0 the first time to track when software is (re)started
This commit is contained in:
parent
05bdc44611
commit
7799e85d7a
1 changed files with 7 additions and 0 deletions
|
@ -3,10 +3,13 @@ package metrics
|
|||
import (
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/safing/portbase/info"
|
||||
)
|
||||
|
||||
var reportedStart atomic.Bool
|
||||
|
||||
func registerInfoMetric() error {
|
||||
meta := info.GetInfo()
|
||||
_, err := NewGauge(
|
||||
|
@ -26,6 +29,10 @@ func registerInfoMetric() error {
|
|||
"comment": commentOption(),
|
||||
},
|
||||
func() float64 {
|
||||
// Report as 0 the first time in order to detect (re)starts.
|
||||
if reportedStart.CompareAndSwap(false, true) {
|
||||
return 0
|
||||
}
|
||||
return 1
|
||||
},
|
||||
nil,
|
||||
|
|
Loading…
Add table
Reference in a new issue