Skip to content

Commit

Permalink
Add drand_start_timestamp metric (#981)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcamou committed May 4, 2022
1 parent 8f795a0 commit f289edf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/drand_daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ func (dd *DrandDaemon) InstantiateBeaconProcess(beaconID string, store key.Store
}
metrics.ReshareStateChange(metrics.ReshareIdle, beaconID, false)
metrics.IsDrandNode.Set(1)
metrics.DrandStartTimestamp.SetToCurrentTime()

return bp, nil
}
Expand Down Expand Up @@ -215,6 +216,7 @@ func (dd *DrandDaemon) RemoveBeaconProcess(beaconID string, bp *BeaconProcess) {
metrics.DKGStateChange(metrics.DKGShutdown, beaconID, false)
metrics.ReshareStateChange(metrics.ReshareShutdown, beaconID, false)
metrics.IsDrandNode.Set(1)
metrics.DrandStartTimestamp.SetToCurrentTime()

dd.state.Unlock()
}
Expand Down
7 changes: 7 additions & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ var (
Help: "State of an outgoing connection. 0=Idle, 1=Connecting, 2=Ready, 3=Transient Failure, 4=Shutdown",
}, []string{"remote_host"})

// DrandStartTimestamp (group) contains the timestamp in seconds since the epoch of the drand process startup
DrandStartTimestamp = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "drand_start_timestamp",
Help: "Timestamp when the drand process started up in seconds since the Epoch",
})

metricsBound = false
)

Expand Down Expand Up @@ -276,6 +282,7 @@ func bindMetrics() error {
reshareLeader,
OutgoingConnectionState,
IsDrandNode,
DrandStartTimestamp,
}
for _, c := range group {
if err := GroupMetrics.Register(c); err != nil {
Expand Down

0 comments on commit f289edf

Please sign in to comment.