diff --git a/consensus/metrics.go b/consensus/metrics.go index 527d53744..d268454fc 100644 --- a/consensus/metrics.go +++ b/consensus/metrics.go @@ -208,14 +208,14 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics { Name: "quorum_prevote_message_delay", Help: "Difference in seconds between the proposal timestamp and the timestamp " + "of the latest prevote that achieved a quorum in the prevote step.", - }, labels).With(labelsAndValues...), + }, append(labels, "height")).With(labelsAndValues...), FullPrevoteMessageDelay: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ Namespace: namespace, Subsystem: MetricsSubsystem, Name: "full_prevote_message_delay", Help: "Difference in seconds between the proposal timestamp and the timestamp " + "of the latest prevote that achieved 100% of the voting power in the prevote step.", - }, labels).With(labelsAndValues...), + }, append(labels, "height")).With(labelsAndValues...), } } diff --git a/consensus/state.go b/consensus/state.go index 9ca9f1d57..b2e1f52a1 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -2294,12 +2294,22 @@ func (cs *State) calculatePrevoteMessageDelayMetrics() { _, val := cs.Validators.GetByAddress(v.ValidatorAddress) votingPowerSeen += val.VotingPower if votingPowerSeen >= cs.Validators.TotalVotingPower()*2/3+1 { - cs.metrics.QuorumPrevoteMessageDelay.Set(v.Timestamp.Sub(cs.Proposal.Timestamp).Seconds()) + delay := v.Timestamp.Sub(cs.Proposal.Timestamp) + if delay >= 10*time.Second { + cs.metrics.QuorumPrevoteMessageDelay.With("height", fmt.Sprintf("%d", cs.Height)).Set(delay.Seconds()) + } else { + cs.metrics.QuorumPrevoteMessageDelay.With("height", "none").Set(delay.Seconds()) + } break } } if ps.HasAll() { - cs.metrics.FullPrevoteMessageDelay.Set(pl[len(pl)-1].Timestamp.Sub(cs.Proposal.Timestamp).Seconds()) + delay := pl[len(pl)-1].Timestamp.Sub(cs.Proposal.Timestamp) + if delay >= 10*time.Second { + cs.metrics.FullPrevoteMessageDelay.With("height", fmt.Sprintf("%d", cs.Height)).Set(delay.Seconds()) + } else { + cs.metrics.FullPrevoteMessageDelay.With("height", "none").Set(delay.Seconds()) + } } }