mirror of
https://github.com/safing/portbase
synced 2025-09-01 18:19:57 +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 (
|
import (
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync/atomic"
|
||||||
|
|
||||||
"github.com/safing/portbase/info"
|
"github.com/safing/portbase/info"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var reportedStart atomic.Bool
|
||||||
|
|
||||||
func registerInfoMetric() error {
|
func registerInfoMetric() error {
|
||||||
meta := info.GetInfo()
|
meta := info.GetInfo()
|
||||||
_, err := NewGauge(
|
_, err := NewGauge(
|
||||||
|
@ -26,6 +29,10 @@ func registerInfoMetric() error {
|
||||||
"comment": commentOption(),
|
"comment": commentOption(),
|
||||||
},
|
},
|
||||||
func() float64 {
|
func() float64 {
|
||||||
|
// Report as 0 the first time in order to detect (re)starts.
|
||||||
|
if reportedStart.CompareAndSwap(false, true) {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
return 1
|
return 1
|
||||||
},
|
},
|
||||||
nil,
|
nil,
|
||||||
|
|
Loading…
Add table
Reference in a new issue