Report mempool size in metrics

pull/7/head
Martin Boehm 2018-06-01 13:37:38 +02:00
parent 17ed8f7d5d
commit eba668bfd1
2 changed files with 13 additions and 1 deletions

View File

@ -153,7 +153,11 @@ func (c *blockChainWithMetrics) SendRawTransaction(tx string) (v string, err err
func (c *blockChainWithMetrics) ResyncMempool(onNewTxAddr func(txid string, addr string)) (count int, err error) {
defer func(s time.Time) { c.observeRPCLatency("ResyncMempool", s, err) }(time.Now())
return c.b.ResyncMempool(onNewTxAddr)
count, err = c.b.ResyncMempool(onNewTxAddr)
if err == nil {
c.m.MempoolSize.Set(float64(count))
}
return count, err
}
func (c *blockChainWithMetrics) GetMempoolTransactions(address string) (v []string, err error) {

View File

@ -18,6 +18,7 @@ type Metrics struct {
IndexResyncErrors *prometheus.CounterVec
IndexDBSize prometheus.Gauge
ExplorerViews *prometheus.CounterVec
MempoolSize prometheus.Gauge
}
type Labels = prometheus.Labels
@ -113,6 +114,13 @@ func GetMetrics(coin string) (*Metrics, error) {
},
[]string{"action"},
)
metrics.MempoolSize = prometheus.NewGauge(
prometheus.GaugeOpts{
Name: "blockbook_mempool_size",
Help: "Mempool size (number of transactions)",
ConstLabels: Labels{"coin": coin},
},
)
v := reflect.ValueOf(metrics)
for i := 0; i < v.NumField(); i++ {