add metric for vote send count

This commit is contained in:
William Banfield
2022-11-23 11:13:17 -05:00
parent f59905d059
commit 7a141c0225
2 changed files with 11 additions and 0 deletions
+9
View File
@@ -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(),
}
}
+2
View File
@@ -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
}