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

core/tracker: add missed participation counter #2075

Merged
merged 1 commit into from
Apr 10, 2023
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
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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dB2510 setting participationGauge to 0 on startup means all peers start a "not participation" which is incorrect since the node didn't have to participate yet, so it hasn't missed or failed participating.

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