-
Notifications
You must be signed in to change notification settings - Fork 211
/
metrics.go
55 lines (46 loc) · 1.11 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
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})
)
// 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()
}