-
Notifications
You must be signed in to change notification settings - Fork 211
/
metrics.go
106 lines (94 loc) · 3.19 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
105
106
package proposals
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/spacemeshos/go-spacemesh/metrics"
)
const (
subsystem = "proposals"
// diffTypeLabel is the label name for the type of different opinions with base block.
diffTypeLabel = "diff_type"
// diffTypeFor is the label value for different opinions with base ballot when voting for blocks.
diffTypeFor = "diff_for"
// diffTypeAgainst is the label value for different opinions with base ballot when voting against blocks.
diffTypeAgainst = "diff_against"
// diffTypeNeutral is the label value for different opinions with base ballot when voting neutral on blocks.
diffTypeNeutral = "diff_neutral"
)
// proposalSize records average size of proposals.
var proposalSize = metrics.NewHistogramWithBuckets(
"proposal_size",
subsystem,
"proposal size in bytes",
[]string{},
prometheus.ExponentialBuckets(100, 2, 8),
)
// numTxsInProposal records average number of transactions in a proposal.
var numTxsInProposal = metrics.NewHistogramWithBuckets(
"num_txs_in_proposal",
subsystem,
"number of transactions in proposal",
[]string{},
prometheus.ExponentialBuckets(1, 2, 8),
)
// numBlocksInException records the number of blocks encoded in a ballot for a given exception type
// (against, for, and neutral).
var numBlocksInException = metrics.NewHistogramWithBuckets(
"num_blocks_in_exception",
subsystem,
"number of blocks in an exception list",
[]string{
diffTypeLabel,
},
prometheus.ExponentialBuckets(1, 2, 8),
)
const (
// labels for each step of proposal/ballot processing.
decodeInit = "decode"
peerHashes = "hashes"
ballot = "ballot"
fetchTXs = "txs"
dbSave = "db_w"
linkTxs = "link"
dataCheck = "data" // check data integrity
fetchRef = "fetch" // check referenced ballots/atxs/blocks are available
decode = "decode" // decoding ballot using tortoise
votes = "votes" // check votes are consistent
eligible = "elig" // check ballot eligibility
)
var (
proposalDuration = metrics.NewHistogramWithBuckets(
"proposal_duration",
subsystem,
"Duration in ns for processing a proposal",
[]string{"step"},
prometheus.ExponentialBuckets(1_000_000, 4, 10),
)
ballotDuration = metrics.NewHistogramWithBuckets(
"ballot_duration",
subsystem,
"Duration in ns for processing a ballot",
[]string{"step"},
prometheus.ExponentialBuckets(1_000_000, 4, 10),
)
)
var (
processErrors = metrics.NewCounter(
"errs",
subsystem,
"number of errors",
[]string{"kind"},
)
malformed = processErrors.WithLabelValues("mal")
failedInit = processErrors.WithLabelValues("init")
known = processErrors.WithLabelValues("known")
tooLate = processErrors.WithLabelValues("late")
tooFuture = processErrors.WithLabelValues("future")
preGenesis = processErrors.WithLabelValues("genesis")
badSigProposal = processErrors.WithLabelValues("sigp")
badSigBallot = processErrors.WithLabelValues("sigb")
badData = processErrors.WithLabelValues("data")
unavailRef = processErrors.WithLabelValues("avail")
badVote = processErrors.WithLabelValues("vote")
notEligible = processErrors.WithLabelValues("elig")
failedPublish = processErrors.WithLabelValues("pub")
)