From 7a141c0225fd7fc5d6caf9f1d23a838433bcee29 Mon Sep 17 00:00:00 2001 From: William Banfield Date: Wed, 23 Nov 2022 11:13:17 -0500 Subject: [PATCH] add metric for vote send count --- consensus/metrics.go | 9 +++++++++ consensus/reactor.go | 2 ++ 2 files changed, 11 insertions(+) diff --git a/consensus/metrics.go b/consensus/metrics.go index 4e9ebe98c..d46734b16 100644 --- a/consensus/metrics.go +++ b/consensus/metrics.go @@ -93,6 +93,8 @@ type Metrics struct { FullPrevoteMessageDelay metrics.Gauge DuplicateVoteReceive metrics.Counter + + VoteSent metrics.Counter } // PrometheusMetrics returns Metrics build using Prometheus client library. @@ -259,6 +261,12 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics { Name: "duplicate_vote_receive", Help: "Number of votes received multiple times from the same peer by peer", }, append(labels, "peer_id", "type")).With(labelsAndValues...), + VoteSent: prometheus.NewCounterFrom(stdprometheus.CounterOpts{ + Namespace: namespace, + Subsystem: MetricsSubsystem, + Name: "vote_sent", + Help: "Number of votes sent by type", + }, append(labels, "type")).With(labelsAndValues...), } } @@ -295,6 +303,7 @@ func NopMetrics() *Metrics { QuorumPrevoteMessageDelay: discard.NewGauge(), FullPrevoteMessageDelay: discard.NewGauge(), DuplicateVoteReceive: discard.NewCounter(), + VoteSent: discard.NewCounter(), } } diff --git a/consensus/reactor.go b/consensus/reactor.go index bf263f65a..afab9d458 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -819,6 +819,7 @@ func (conR *Reactor) gossipVotesForHeight( // If there are prevotes to send... if prs.Step <= cstypes.RoundStepPrevoteWait && prs.Round != -1 && prs.Round <= rs.Round { if ps.PickSendVote(rs.Votes.Prevotes(prs.Round)) { + conR.Metrics.VoteSent.With("type", "prevote").Add(1) logger.Debug("Picked rs.Prevotes(prs.Round) to send", "round", prs.Round) return true } @@ -826,6 +827,7 @@ func (conR *Reactor) gossipVotesForHeight( // If there are precommits to send... if prs.Step <= cstypes.RoundStepPrecommitWait && prs.Round != -1 && prs.Round <= rs.Round { if ps.PickSendVote(rs.Votes.Precommits(prs.Round)) { + conR.Metrics.VoteSent.With("type", "precommit").Add(1) logger.Debug("Picked rs.Precommits(prs.Round) to send", "round", prs.Round) return true }