From 7da95d62978cb659577315621a1c1a67d839319b Mon Sep 17 00:00:00 2001 From: egonspace Date: Tue, 27 Apr 2021 14:13:53 +0900 Subject: [PATCH] chore: fix the type of consensus_block_interval_seconds from histogram to gauge (#224) --- consensus/metrics.go | 6 +++--- consensus/state.go | 2 +- test/maverick/consensus/state.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/consensus/metrics.go b/consensus/metrics.go index ab275d0cd..95e295967 100644 --- a/consensus/metrics.go +++ b/consensus/metrics.go @@ -48,7 +48,7 @@ type Metrics struct { ByzantineVotersPower metrics.Gauge // Time between this and the last block. - BlockIntervalSeconds metrics.Histogram + BlockIntervalSeconds metrics.Gauge // Number of transactions. NumTxs metrics.Gauge @@ -173,7 +173,7 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics { Name: "byzantine_voters_power", Help: "Total power of the byzantine voters.", }, labels).With(labelsAndValues...), - BlockIntervalSeconds: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{ + BlockIntervalSeconds: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ Namespace: namespace, Subsystem: MetricsSubsystem, Name: "block_interval_seconds", @@ -327,7 +327,7 @@ func NopMetrics() *Metrics { ByzantineVoters: discard.NewGauge(), ByzantineVotersPower: discard.NewGauge(), - BlockIntervalSeconds: discard.NewHistogram(), + BlockIntervalSeconds: discard.NewGauge(), NumTxs: discard.NewGauge(), BlockSizeBytes: discard.NewGauge(), diff --git a/consensus/state.go b/consensus/state.go index f2d961f86..c67341889 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -1877,7 +1877,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.Observe( + cs.metrics.BlockIntervalSeconds.Set( block.Time.Sub(lastBlockMeta.Header.Time).Seconds(), ) } diff --git a/test/maverick/consensus/state.go b/test/maverick/consensus/state.go index 0cf69efba..c31d2eb41 100644 --- a/test/maverick/consensus/state.go +++ b/test/maverick/consensus/state.go @@ -1649,7 +1649,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.Observe( + cs.metrics.BlockIntervalSeconds.Set( block.Time.Sub(lastBlockMeta.Header.Time).Seconds(), ) }