Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit DKG/Reshare status when node starts up/shuts down #955

Merged
merged 6 commits into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions core/drand_daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ func (dd *DrandDaemon) InstantiateBeaconProcess(beaconID string, store key.Store
dd.beaconProcesses[beaconID] = bp
dd.state.Unlock()

metrics.DKGStateChange(metrics.DKGNotStarted, beaconID, false)
metrics.ReshareStateChange(metrics.ReshareIdle, beaconID, false)
metrics.IsDrandNode.Set(1)

return bp, nil
}

Expand Down Expand Up @@ -204,6 +208,10 @@ func (dd *DrandDaemon) RemoveBeaconProcess(beaconID string, bp *BeaconProcess) {
delete(dd.chainHashes, common.DefaultChainHash)
}

metrics.DKGStateChange(metrics.DKGShutdown, beaconID, false)
metrics.ReshareStateChange(metrics.ReshareShutdown, beaconID, false)
metrics.IsDrandNode.Set(1)

dd.state.Unlock()
}

Expand Down
12 changes: 10 additions & 2 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ const (
DKGWaiting DKGStatus = "waiting"
DKGReady DKGStatus = "ready"
DKGUnknownStatus DKGStatus = "unknown"
DKGShutdown DKGStatus = "node_stopped"
)

const (
ReshareIdle ReshareStatus = "idle"
ReshareWaiting ReshareStatus = "waiting"
ReshareInProgess ReshareStatus = "in_progress"
ReshareStatusUnknown ReshareStatus = "unknown"
ReshareShutdown ReshareStatus = "node_stopped"
)

var (
Expand Down Expand Up @@ -177,14 +179,14 @@ var (
Name: "dkg_state_change_timestamp",
Help: "DKG state change timestamp in seconds since the Epoch",
ConstLabels: map[string]string{},
}, []string{"state", "beacon_id", "is_leader"})
}, []string{"dkg_state", "beacon_id", "is_leader"})

// reshareStateChangeTimestamp tracks reshare status changes
reshareStateChangeTimestamp = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "reshare_state_change_timestamp",
Help: "Reshare state change timestamp in seconds since the Epoch",
ConstLabels: map[string]string{},
}, []string{"state", "beacon_id", "is_leader"})
}, []string{"reshare_state", "beacon_id", "is_leader"})

// drandBuildTime emits the timestamp when the binary was built in Unix time.
drandBuildTime = prometheus.NewUntypedFunc(prometheus.UntypedOpts{
Expand All @@ -193,6 +195,12 @@ var (
ConstLabels: map[string]string{"build": common.COMMIT, "version": common.GetAppVersion().String()},
}, func() float64 { return float64(getBuildTimestamp(common.BUILDDATE)) })

// IsDrandNode is 1 for drand nodes, 0 for relays
IsDrandNode = prometheus.NewGauge(prometheus.GaugeOpts{
AnomalRoil marked this conversation as resolved.
Show resolved Hide resolved
Name: "is_drand_node",
Help: "1 for drand nodes, not emitted for relays",
})

metricsBound = false
)

Expand Down