Skip to content

Commit

Permalink
chore: fix the type of consensus_block_interval_seconds from histogra…
Browse files Browse the repository at this point in the history
…m to gauge (#224)
  • Loading branch information
egonspace committed Jul 8, 2021
1 parent 94c8980 commit 7da95d6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions consensus/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)
}
Expand Down
2 changes: 1 addition & 1 deletion test/maverick/consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)
}
Expand Down

0 comments on commit 7da95d6

Please sign in to comment.