diff --git a/mempool/cat/pool.go b/mempool/cat/pool.go index efe644f809..a1a86e1ef4 100644 --- a/mempool/cat/pool.go +++ b/mempool/cat/pool.go @@ -499,6 +499,7 @@ func (txmp *TxPool) Update( // transactions are left. size := txmp.Size() txmp.metrics.Size.Set(float64(size)) + txmp.metrics.SizeBytes.Set(float64(txmp.SizeBytes())) if size > 0 { if txmp.config.Recheck { txmp.recheckTransactions() @@ -576,6 +577,7 @@ func (txmp *TxPool) addNewTransaction(wtx *wrappedTx, checkTxRes *abci.ResponseC txmp.metrics.TxSizeBytes.Observe(float64(wtx.size())) txmp.metrics.Size.Set(float64(txmp.Size())) + txmp.metrics.SizeBytes.Set(float64(txmp.SizeBytes())) txmp.logger.Debug( "inserted new valid transaction", "priority", wtx.priority, @@ -628,6 +630,7 @@ func (txmp *TxPool) handleRecheckResult(wtx *wrappedTx, checkTxRes *abci.Respons } txmp.metrics.FailedTxs.Add(1) txmp.metrics.Size.Set(float64(txmp.Size())) + txmp.metrics.SizeBytes.Set(float64(txmp.SizeBytes())) } // recheckTransactions initiates re-CheckTx ABCI calls for all the transactions diff --git a/mempool/metrics.go b/mempool/metrics.go index 6c00ce59bc..7c23a5f94b 100644 --- a/mempool/metrics.go +++ b/mempool/metrics.go @@ -30,6 +30,9 @@ type Metrics struct { // Size of the mempool. Size metrics.Gauge + // Total size of the mempool in bytes. + SizeBytes metrics.Gauge + // Histogram of transaction sizes, in bytes. TxSizeBytes metrics.Histogram @@ -81,6 +84,13 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics { Help: "Size of the mempool (number of uncommitted transactions).", }, labels).With(labelsAndValues...), + SizeBytes: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ + Namespace: namespace, + Subsystem: MetricsSubsystem, + Name: "size_bytes", + Help: "Total size of the mempool in bytes.", + }, labels).With(labelsAndValues...), + TxSizeBytes: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{ Namespace: namespace, Subsystem: MetricsSubsystem, @@ -144,6 +154,7 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics { func NopMetrics() *Metrics { return &Metrics{ Size: discard.NewGauge(), + SizeBytes: discard.NewGauge(), TxSizeBytes: discard.NewHistogram(), FailedTxs: discard.NewCounter(), EvictedTxs: discard.NewCounter(), diff --git a/mempool/v0/clist_mempool.go b/mempool/v0/clist_mempool.go index 17dda10487..e81083cac8 100644 --- a/mempool/v0/clist_mempool.go +++ b/mempool/v0/clist_mempool.go @@ -277,6 +277,7 @@ func (mem *CListMempool) globalCb(req *abci.Request, res *abci.Response) { // update metrics mem.metrics.Size.Set(float64(mem.Size())) + mem.metrics.SizeBytes.Set(float64(mem.SizeBytes())) } // Request specific callback that should be set on individual reqRes objects @@ -304,6 +305,7 @@ func (mem *CListMempool) reqResCb( // update metrics mem.metrics.Size.Set(float64(mem.Size())) + mem.metrics.SizeBytes.Set(float64(mem.SizeBytes())) // passed in by the caller of CheckTx, eg. the RPC if externalCb != nil { @@ -639,6 +641,7 @@ func (mem *CListMempool) Update( // Update metrics mem.metrics.Size.Set(float64(mem.Size())) + mem.metrics.SizeBytes.Set(float64(mem.SizeBytes())) return nil } diff --git a/mempool/v1/mempool.go b/mempool/v1/mempool.go index d3736ef74f..c7191fad9c 100644 --- a/mempool/v1/mempool.go +++ b/mempool/v1/mempool.go @@ -439,6 +439,7 @@ func (txmp *TxMempool) Update( // transactions are left. size := txmp.Size() txmp.metrics.Size.Set(float64(size)) + txmp.metrics.SizeBytes.Set(float64(txmp.SizeBytes())) if size > 0 { if txmp.config.Recheck { txmp.recheckTransactions() @@ -608,6 +609,7 @@ func (txmp *TxMempool) addNewTransaction(wtx *WrappedTx, checkTxRes *abci.Respon txmp.metrics.TxSizeBytes.Observe(float64(wtx.Size())) txmp.metrics.Size.Set(float64(txmp.Size())) + txmp.metrics.SizeBytes.Set(float64(txmp.SizeBytes())) txmp.logger.Debug( "inserted new valid transaction", "priority", wtx.Priority(), @@ -675,6 +677,7 @@ func (txmp *TxMempool) handleRecheckResult(tx types.Tx, checkTxRes *abci.Respons } } txmp.metrics.Size.Set(float64(txmp.Size())) + txmp.metrics.SizeBytes.Set(float64(txmp.SizeBytes())) } // recheckTransactions initiates re-CheckTx ABCI calls for all the transactions