2019-10-29 17:51:17 +00:00
|
|
|
package core
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Metrics for monitoring service.
|
|
|
|
var (
|
2023-04-13 10:49:07 +00:00
|
|
|
// blockHeight prometheus metric.
|
2019-10-29 17:51:17 +00:00
|
|
|
blockHeight = prometheus.NewGauge(
|
|
|
|
prometheus.GaugeOpts{
|
|
|
|
Help: "Current index of processed block",
|
|
|
|
Name: "current_block_height",
|
|
|
|
Namespace: "neogo",
|
|
|
|
},
|
|
|
|
)
|
2023-04-13 10:49:07 +00:00
|
|
|
// persistedHeight prometheus metric.
|
2019-10-29 17:51:17 +00:00
|
|
|
persistedHeight = prometheus.NewGauge(
|
|
|
|
prometheus.GaugeOpts{
|
|
|
|
Help: "Current persisted block count",
|
|
|
|
Name: "current_persisted_height",
|
|
|
|
Namespace: "neogo",
|
|
|
|
},
|
|
|
|
)
|
2023-04-13 10:49:07 +00:00
|
|
|
// headerHeight prometheus metric.
|
2019-10-29 17:51:17 +00:00
|
|
|
headerHeight = prometheus.NewGauge(
|
|
|
|
prometheus.GaugeOpts{
|
|
|
|
Help: "Current header height",
|
|
|
|
Name: "current_header_height",
|
|
|
|
Namespace: "neogo",
|
|
|
|
},
|
|
|
|
)
|
2023-04-13 11:03:02 +00:00
|
|
|
// mempoolUnsortedTx prometheus metric.
|
|
|
|
mempoolUnsortedTx = prometheus.NewGauge(
|
|
|
|
prometheus.GaugeOpts{
|
|
|
|
Help: "Mempool unsorted transactions",
|
|
|
|
Name: "mempool_unsorted_tx",
|
|
|
|
Namespace: "neogo",
|
|
|
|
},
|
|
|
|
)
|
2019-10-29 17:51:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
prometheus.MustRegister(
|
|
|
|
blockHeight,
|
|
|
|
persistedHeight,
|
|
|
|
headerHeight,
|
2023-04-13 11:03:02 +00:00
|
|
|
mempoolUnsortedTx,
|
2019-10-29 17:51:17 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func updatePersistedHeightMetric(pHeight uint32) {
|
|
|
|
persistedHeight.Set(float64(pHeight))
|
|
|
|
}
|
|
|
|
|
2022-11-18 20:19:50 +00:00
|
|
|
func updateHeaderHeightMetric(hHeight uint32) {
|
2019-10-29 17:51:17 +00:00
|
|
|
headerHeight.Set(float64(hHeight))
|
|
|
|
}
|
|
|
|
|
|
|
|
func updateBlockHeightMetric(bHeight uint32) {
|
|
|
|
blockHeight.Set(float64(bHeight))
|
|
|
|
}
|
2023-04-13 11:03:02 +00:00
|
|
|
|
|
|
|
// updateMempoolMetrics updates metric of the number of unsorted txs inside the mempool.
|
|
|
|
func updateMempoolMetrics(unsortedTxnLen int) {
|
|
|
|
mempoolUnsortedTx.Set(float64(unsortedTxnLen))
|
|
|
|
}
|