diff --git a/consensus/metrics.go b/consensus/metrics.go index 86bbf678f..bbd823a3f 100644 --- a/consensus/metrics.go +++ b/consensus/metrics.go @@ -43,7 +43,7 @@ type Metrics struct { ByzantineValidatorsPower metrics.Gauge // Time between this and the last block. - BlockIntervalSeconds metrics.Gauge + BlockIntervalSeconds metrics.Histogram // Number of transactions. NumTxs metrics.Gauge @@ -138,7 +138,7 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics { Name: "byzantine_validators_power", Help: "Total power of the byzantine validators.", }, labels).With(labelsAndValues...), - BlockIntervalSeconds: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ + BlockIntervalSeconds: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{ Namespace: namespace, Subsystem: MetricsSubsystem, Name: "block_interval_seconds", @@ -207,7 +207,7 @@ func NopMetrics() *Metrics { ByzantineValidators: discard.NewGauge(), ByzantineValidatorsPower: discard.NewGauge(), - BlockIntervalSeconds: discard.NewGauge(), + BlockIntervalSeconds: discard.NewHistogram(), NumTxs: discard.NewGauge(), BlockSizeBytes: discard.NewGauge(), diff --git a/consensus/state.go b/consensus/state.go index 25f599cfe..61a85d136 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -1655,7 +1655,7 @@ func (cs *State) recordMetrics(height int64, block *types.Block) { if height > 1 { lastBlockMeta := cs.blockStore.LoadBlockMeta(height - 1) if lastBlockMeta != nil { - cs.metrics.BlockIntervalSeconds.Set( + cs.metrics.BlockIntervalSeconds.Observe( block.Time.Sub(lastBlockMeta.Header.Time).Seconds(), ) }