github.com/nspcc-dev/neo-go@v0.105.2-0.20240517133400-6be757af3eba/pkg/core/prometheus.go (about) 1 package core 2 3 import ( 4 "github.com/prometheus/client_golang/prometheus" 5 ) 6 7 // Metrics for monitoring service. 8 var ( 9 // blockHeight prometheus metric. 10 blockHeight = prometheus.NewGauge( 11 prometheus.GaugeOpts{ 12 Help: "Current index of processed block", 13 Name: "current_block_height", 14 Namespace: "neogo", 15 }, 16 ) 17 // persistedHeight prometheus metric. 18 persistedHeight = prometheus.NewGauge( 19 prometheus.GaugeOpts{ 20 Help: "Current persisted block count", 21 Name: "current_persisted_height", 22 Namespace: "neogo", 23 }, 24 ) 25 // headerHeight prometheus metric. 26 headerHeight = prometheus.NewGauge( 27 prometheus.GaugeOpts{ 28 Help: "Current header height", 29 Name: "current_header_height", 30 Namespace: "neogo", 31 }, 32 ) 33 // mempoolUnsortedTx prometheus metric. 34 mempoolUnsortedTx = prometheus.NewGauge( 35 prometheus.GaugeOpts{ 36 Help: "Mempool unsorted transactions", 37 Name: "mempool_unsorted_tx", 38 Namespace: "neogo", 39 }, 40 ) 41 ) 42 43 func init() { 44 prometheus.MustRegister( 45 blockHeight, 46 persistedHeight, 47 headerHeight, 48 mempoolUnsortedTx, 49 ) 50 } 51 52 func updatePersistedHeightMetric(pHeight uint32) { 53 persistedHeight.Set(float64(pHeight)) 54 } 55 56 func updateHeaderHeightMetric(hHeight uint32) { 57 headerHeight.Set(float64(hHeight)) 58 } 59 60 func updateBlockHeightMetric(bHeight uint32) { 61 blockHeight.Set(float64(bHeight)) 62 } 63 64 // updateMempoolMetrics updates metric of the number of unsorted txs inside the mempool. 65 func updateMempoolMetrics(unsortedTxnLen int) { 66 mempoolUnsortedTx.Set(float64(unsortedTxnLen)) 67 }