-
Notifications
You must be signed in to change notification settings - Fork 211
/
metrics.go
104 lines (91 loc) · 2.38 KB
/
metrics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package syncer
import (
"github.com/spacemeshos/go-spacemesh/metrics"
)
const (
namespace = "syncer"
)
var (
numRuns = metrics.NewCounter(
"runs",
namespace,
"number of sync runs",
[]string{"outcome"},
)
runSuccess = numRuns.WithLabelValues("ok")
runFail = numRuns.WithLabelValues("not")
stateRuns = metrics.NewCounter(
"state_runs",
namespace,
"number of state sync runs",
[]string{"outcome"},
)
sRunSuccess = stateRuns.WithLabelValues("ok")
sRunFail = stateRuns.WithLabelValues("not")
syncedLayers = metrics.NewGauge(
"layers",
namespace,
"synced layers in different data type",
[]string{"data"},
)
dataLayer = syncedLayers.WithLabelValues("data")
opinionLayer = syncedLayers.WithLabelValues("opinion")
syncedEpochs = metrics.NewGauge(
"epochs",
namespace,
"synced epochs in different data type",
[]string{"data"},
)
atxEpoch = syncedEpochs.WithLabelValues("atx")
nodeSyncState = metrics.NewGauge(
"sync_state",
namespace,
"node sync state in [not_synced, gossip, synced]",
[]string{"state"},
)
nodeNotSynced = nodeSyncState.WithLabelValues("not")
nodeGossip = nodeSyncState.WithLabelValues("gossip")
nodeSynced = nodeSyncState.WithLabelValues("synced")
atxSynced = nodeSyncState.WithLabelValues("atx_synced")
numHashResolution = metrics.NewCounter(
"hash_resolution",
namespace,
"number of hash resolution with peers",
[]string{"outcome"},
)
hashResolve = numHashResolution.WithLabelValues("ok")
hashResolveFail = numHashResolution.WithLabelValues("not")
numCertAdopted = metrics.NewCounter(
"adopted_cert",
namespace,
"number of cert adopted",
[]string{},
).WithLabelValues()
syncedLayer = metrics.NewGauge(
"layer",
namespace,
"synced layer",
[]string{},
).WithLabelValues()
peerError = metrics.NewCounter(
"peer_error",
namespace,
"total number of errors by peers",
[]string{"kind"})
layerPeerError = peerError.WithLabelValues("layer")
opnsPeerError = peerError.WithLabelValues("opns")
certPeerError = peerError.WithLabelValues("cert")
MalPeerError = peerError.WithLabelValues("mal")
v2OpnPoll = metrics.NewCounter(
"opn_poll",
namespace,
"number of times opinions are polled",
[]string{"version"},
).WithLabelValues("v2")
v2OpnErr = metrics.NewCounter(
"opn_err",
namespace,
"number of times opinions poll failed",
[]string{"version"},
).WithLabelValues("v2")
)