-
Notifications
You must be signed in to change notification settings - Fork 211
/
metrics.go
74 lines (62 loc) · 1.52 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
package fetch
import (
"github.com/spacemeshos/go-spacemesh/datastore"
"github.com/spacemeshos/go-spacemesh/metrics"
)
const (
// subsystem shared by all metrics exposed by this package.
subsystem = "fetch"
hint = "hint"
)
var (
totalHits = metrics.NewCounter(
"cache_hits",
subsystem,
"Total hash-to-peer cache hits",
[]string{hint})
total = metrics.NewCounter(
"cache_lookup",
subsystem,
"Total hash-to-peer cache lookups",
[]string{hint})
totalHashReqs = metrics.NewCounter(
"hash_reqs",
subsystem,
"total hash requests",
[]string{hint})
hashMissing = metrics.NewCounter(
"hash_missing",
subsystem,
"total requests that hash is not present locally",
[]string{hint})
hashEmptyData = metrics.NewCounter(
"hash_empty",
subsystem,
"total request that hash has no data",
[]string{hint})
peerErrors = metrics.NewCounter(
"hash_peer_err",
subsystem,
"total error from sending peers hash requests",
[]string{hint})
certReq = metrics.NewCounter(
"certs",
subsystem,
"total requests for block certificate received",
[]string{}).WithLabelValues()
opnReqV2 = metrics.NewCounter(
"opn_reqs",
subsystem,
"total layer opinion requests received",
[]string{"version"},
).WithLabelValues("v2")
)
// logCacheHit logs cache hit.
func logCacheHit(hint datastore.Hint) {
totalHits.WithLabelValues(string(hint)).Inc()
total.WithLabelValues(string(hint)).Inc()
}
// logCacheMiss logs cache miss.
func logCacheMiss(hint datastore.Hint) {
total.WithLabelValues(string(hint)).Inc()
}