Skip to content

Commit

Permalink
core/tracker: add missed participation counter (#2075)
Browse files Browse the repository at this point in the history
Adds a `missed participation by peer` counter so that we can calculate `duty participation % per peer` and so we can highlight missed participations instead of only successful participations.

category: misc
ticket: #2034
  • Loading branch information
corverroos authored Apr 10, 2023
1 parent e8acdbc commit ee11175
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 8 additions & 1 deletion core/tracker/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,20 @@ var (
Help: "Set to 1 if peer participated successfully for the given duty or else 0",
}, []string{"duty", "peer"})

participationCounter = promauto.NewCounterVec(prometheus.CounterOpts{
participationSuccess = promauto.NewCounterVec(prometheus.CounterOpts{
Namespace: "core",
Subsystem: "tracker",
Name: "participation_total",
Help: "Total number of successful participations by peer and duty type",
}, []string{"duty", "peer"})

participationMissed = promauto.NewCounterVec(prometheus.CounterOpts{
Namespace: "core",
Subsystem: "tracker",
Name: "participation_missed_total",
Help: "Total number of missed participations by peer and duty type",
}, []string{"duty", "peer"})

failedCounter = promauto.NewCounterVec(prometheus.CounterOpts{
Namespace: "core",
Subsystem: "tracker",
Expand Down
7 changes: 4 additions & 3 deletions core/tracker/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,8 @@ func newParticipationReporter(peers []p2p.Peer) func(context.Context, core.Duty,
// Initialise participation metrics to 0 to avoid non-existent metrics issue on startup.
for _, duty := range core.AllDutyTypes() {
for _, peer := range peers {
participationCounter.WithLabelValues(duty.String(), peer.Name).Add(0)
participationGauge.WithLabelValues(duty.String(), peer.Name).Set(0)
participationSuccess.WithLabelValues(duty.String(), peer.Name).Add(0)
participationMissed.WithLabelValues(duty.String(), peer.Name).Add(0)
}
}

Expand All @@ -687,13 +687,14 @@ func newParticipationReporter(peers []p2p.Peer) func(context.Context, core.Duty,
for _, peer := range peers {
if participatedShares[peer.ShareIdx()] {
participationGauge.WithLabelValues(duty.Type.String(), peer.Name).Set(1)
participationCounter.WithLabelValues(duty.Type.String(), peer.Name).Inc()
participationSuccess.WithLabelValues(duty.Type.String(), peer.Name).Inc()
} else if unexpectedShares[peer.ShareIdx()] {
log.Warn(ctx, "Unexpected event found", nil, z.Str("peer", peer.Name), z.Str("duty", duty.String()))
unexpectedEventsCounter.WithLabelValues(peer.Name).Inc()
} else {
absentPeers = append(absentPeers, peer.Name)
participationGauge.WithLabelValues(duty.Type.String(), peer.Name).Set(0)
participationMissed.WithLabelValues(duty.Type.String(), peer.Name).Inc()
}
}

Expand Down

0 comments on commit ee11175

Please sign in to comment.