Browse Source

metrics: change blocksize to a histogram (#6549)

## Description

Change block_size gauge to a histogram to observe block size overtime

This will help will see which chains have full blocks vs empty. 

closes #5752
pull/6554/head
Marko 3 years ago
committed by GitHub
parent
commit
2f6141645b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 4 deletions
  1. +1
    -0
      CHANGELOG_PENDING.md
  2. +3
    -3
      internal/consensus/metrics.go
  3. +1
    -1
      internal/consensus/state.go

+ 1
- 0
CHANGELOG_PENDING.md View File

@ -118,6 +118,7 @@ Friendly reminder: We have a [bug bounty program](https://hackerone.com/tendermi
- [crypto/merkle] \#6443 Improve HashAlternatives performance (@cuonglm)
- [crypto/merkle] \#6513 Optimize HashAlternatives (@marbar3778)
- [p2p/pex] \#6509 Improve addrBook.hash performance (@cuonglm)
- [consensus/metrics] \#6549 Change block_size gauge to a histogram for better observability over time (@marbar3778)
### BUG FIXES


+ 3
- 3
internal/consensus/metrics.go View File

@ -48,7 +48,7 @@ type Metrics struct {
// Number of transactions.
NumTxs metrics.Gauge
// Size of the block.
BlockSizeBytes metrics.Gauge
BlockSizeBytes metrics.Histogram
// Total number of transactions.
TotalTxs metrics.Gauge
// The latest block height.
@ -150,7 +150,7 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics {
Name: "num_txs",
Help: "Number of transactions.",
}, labels).With(labelsAndValues...),
BlockSizeBytes: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
BlockSizeBytes: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
Namespace: namespace,
Subsystem: MetricsSubsystem,
Name: "block_size_bytes",
@ -210,7 +210,7 @@ func NopMetrics() *Metrics {
BlockIntervalSeconds: discard.NewHistogram(),
NumTxs: discard.NewGauge(),
BlockSizeBytes: discard.NewGauge(),
BlockSizeBytes: discard.NewHistogram(),
TotalTxs: discard.NewGauge(),
CommittedHeight: discard.NewGauge(),
FastSyncing: discard.NewGauge(),


+ 1
- 1
internal/consensus/state.go View File

@ -1809,7 +1809,7 @@ func (cs *State) recordMetrics(height int64, block *types.Block) {
cs.metrics.NumTxs.Set(float64(len(block.Data.Txs)))
cs.metrics.TotalTxs.Add(float64(len(block.Data.Txs)))
cs.metrics.BlockSizeBytes.Set(float64(block.Size()))
cs.metrics.BlockSizeBytes.Observe(float64(block.Size()))
cs.metrics.CommittedHeight.Set(float64(block.Height))
}


Loading…
Cancel
Save