Fix state/storage counter metrics.
All checks were successful
Test / Run unit and integration tests (pull_request) Successful in 4m41s
Test / Run compliance tests (pull_request) Successful in 5m25s

This commit is contained in:
Thomas E Lackey 2023-10-09 12:54:08 -05:00
parent b4367dff3b
commit ede2fc85a7
2 changed files with 6 additions and 42 deletions

View File

@ -33,9 +33,6 @@ var (
stateNodeCount prometheus.Counter
storageNodeCount prometheus.Counter
codeNodeCount prometheus.Counter
activeIteratorCount prometheus.Gauge
)
func Init() {
@ -54,20 +51,6 @@ func Init() {
Name: "storage_node_count",
Help: "Number of storage nodes processed",
})
codeNodeCount = promauto.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Subsystem: statsSubsystem,
Name: "code_node_count",
Help: "Number of code nodes processed",
})
activeIteratorCount = promauto.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: statsSubsystem,
Name: "active_iterator_count",
Help: "Number of active iterators",
})
}
func RegisterGaugeFunc(name string, function func() float64) {
@ -94,31 +77,10 @@ func IncStateNodeCount() {
}
}
// IncStorageNodeCount increments the number of storage nodes processed
func IncStorageNodeCount() {
if metrics {
storageNodeCount.Inc()
}
}
// IncCodeNodeCount increments the number of code nodes processed
func IncCodeNodeCount() {
if metrics {
codeNodeCount.Inc()
}
}
// IncActiveIterCount increments the number of active iterators
func IncActiveIterCount() {
if metrics {
activeIteratorCount.Inc()
}
}
// DecActiveIterCount decrements the number of active iterators
func DecActiveIterCount() {
if metrics {
activeIteratorCount.Dec()
// AddStorageNodeCount increments the number of storage nodes processed
func AddStorageNodeCount(count int) {
if metrics && count > 0 {
storageNodeCount.Add(float64(count))
}
}

View File

@ -124,6 +124,8 @@ func (s *Service) CreateSnapshot(params SnapshotParams) error {
nodeSink := func(node types.StateLeafNode) error {
nodeMtx.Lock()
defer nodeMtx.Unlock()
prom.IncStateNodeCount()
prom.AddStorageNodeCount(len(node.StorageDiff))
return s.indexer.PushStateNode(tx, node, headerid)
}
ipldSink := func(c types.IPLD) error {