@@ -15,26 +15,25 @@ var (
15
15
isMonitoringActive bool
16
16
nodePublicKey []byte
17
17
18
- receiptCounter prometheus.Counter
19
- unresolvedPeersCounter prometheus.Gauge
20
- resolvedPeersCounter prometheus.Gauge
21
- unresolvedPriorityPeersCounter prometheus.Gauge
22
- resolvedPriorityPeersCounter prometheus.Gauge
23
- activeRegisteredNodesGauge prometheus.Gauge
24
- nodeScore prometheus.Gauge
25
- blockerCounterVector * prometheus.CounterVec
26
- statusLockGaugeVector * prometheus.GaugeVec
27
- blockchainStatusGaugeVector * prometheus.GaugeVec
28
- blockchainSmithTimeGaugeVector * prometheus.GaugeVec
29
- blockchainIDMsbGaugeVector * prometheus.GaugeVec
30
- blockchainIDLsbGaugeVector * prometheus.GaugeVec
31
- blockchainHeightGaugeVector * prometheus.GaugeVec
32
- goRoutineActivityGaugeVector * prometheus.GaugeVec
33
- downloadCycleDebuggerGaugeVector * prometheus.GaugeVec
34
- apiGaugeVector * prometheus.GaugeVec
35
- apiRunningGaugeVector * prometheus.GaugeVec
36
- snapshotDownloadRequestCounter prometheus.Counter
37
- snapshotDownloadRequestFailedCounter prometheus.Counter
18
+ receiptCounter prometheus.Counter
19
+ unresolvedPeersCounter prometheus.Gauge
20
+ resolvedPeersCounter prometheus.Gauge
21
+ unresolvedPriorityPeersCounter prometheus.Gauge
22
+ resolvedPriorityPeersCounter prometheus.Gauge
23
+ activeRegisteredNodesGauge prometheus.Gauge
24
+ nodeScore prometheus.Gauge
25
+ blockerCounterVector * prometheus.CounterVec
26
+ statusLockGaugeVector * prometheus.GaugeVec
27
+ blockchainStatusGaugeVector * prometheus.GaugeVec
28
+ blockchainSmithTimeGaugeVector * prometheus.GaugeVec
29
+ blockchainIDMsbGaugeVector * prometheus.GaugeVec
30
+ blockchainIDLsbGaugeVector * prometheus.GaugeVec
31
+ blockchainHeightGaugeVector * prometheus.GaugeVec
32
+ goRoutineActivityGaugeVector * prometheus.GaugeVec
33
+ downloadCycleDebuggerGaugeVector * prometheus.GaugeVec
34
+ apiGaugeVector * prometheus.GaugeVec
35
+ apiRunningGaugeVector * prometheus.GaugeVec
36
+ snapshotDownloadRequestCounter * prometheus.CounterVec
38
37
)
39
38
40
39
const (
@@ -111,7 +110,7 @@ func SetMonitoringActive(isActive bool) {
111
110
statusLockGaugeVector = prometheus .NewGaugeVec (prometheus.GaugeOpts {
112
111
Name : "zoobc_status_lock" ,
113
112
Help : "Status lock counter" ,
114
- }, []string {"blocker_type " })
113
+ }, []string {"chaintype" , "status_type " })
115
114
prometheus .MustRegister (statusLockGaugeVector )
116
115
117
116
blockchainStatusGaugeVector = prometheus .NewGaugeVec (prometheus.GaugeOpts {
@@ -174,12 +173,11 @@ func SetMonitoringActive(isActive bool) {
174
173
}, []string {"api_name" })
175
174
prometheus .MustRegister (apiRunningGaugeVector )
176
175
177
- snapshotDownloadRequestFailedCounter = prometheus .NewCounter (prometheus.CounterOpts {
178
- Name : fmt .Sprintf ("zoobc_snapshot_chunk_downloads_failed" ),
179
- Help : fmt .Sprintf ("snapshot file chunks failed to download" ),
180
- })
181
- prometheus .MustRegister (snapshotDownloadRequestFailedCounter )
182
-
176
+ snapshotDownloadRequestCounter = prometheus .NewCounterVec (prometheus.CounterOpts {
177
+ Name : fmt .Sprintf ("zoobc_snapshot_chunk_downloads_status" ),
178
+ Help : fmt .Sprintf ("snapshot file chunks to download" ),
179
+ }, []string {"status" })
180
+ prometheus .MustRegister (snapshotDownloadRequestCounter )
183
181
}
184
182
185
183
func SetNodePublicKey (pk []byte ) {
@@ -246,20 +244,20 @@ func IncrementBlockerMetrics(typeBlocker string) {
246
244
blockerCounterVector .WithLabelValues (typeBlocker ).Inc ()
247
245
}
248
246
249
- func IncrementStatusLockCounter (typeStatusLock int ) {
247
+ func IncrementStatusLockCounter (chaintype chaintype. ChainType , typeStatusLock int ) {
250
248
if ! isMonitoringActive {
251
249
return
252
250
}
253
251
254
- statusLockGaugeVector .WithLabelValues (fmt .Sprintf ("%d" , typeStatusLock )).Inc ()
252
+ statusLockGaugeVector .WithLabelValues (chaintype . GetName (), fmt .Sprintf ("%d" , typeStatusLock )).Inc ()
255
253
}
256
254
257
- func DecrementStatusLockCounter (typeStatusLock int ) {
255
+ func DecrementStatusLockCounter (chaintype chaintype. ChainType , typeStatusLock int ) {
258
256
if ! isMonitoringActive {
259
257
return
260
258
}
261
259
262
- statusLockGaugeVector .WithLabelValues (fmt .Sprintf ("%d" , typeStatusLock )).Dec ()
260
+ statusLockGaugeVector .WithLabelValues (chaintype . GetName (), fmt .Sprintf ("%d" , typeStatusLock )).Dec ()
263
261
}
264
262
265
263
func SetBlockchainStatus (chainType chaintype.ChainType , newStatus int ) {
@@ -366,9 +364,9 @@ func IncrementSnapshotDownloadCounter(succeeded, failed int32) {
366
364
}
367
365
368
366
if succeeded > 0 {
369
- snapshotDownloadRequestCounter .Add (float64 (succeeded ))
367
+ snapshotDownloadRequestCounter .WithLabelValues ( "success" ). Add (float64 (succeeded ))
370
368
}
371
369
if failed > 0 {
372
- snapshotDownloadRequestFailedCounter .Add (float64 (failed ))
370
+ snapshotDownloadRequestCounter . WithLabelValues ( "failed" ) .Add (float64 (failed ))
373
371
}
374
372
}
0 commit comments