forked from grafana/groupcache_exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
adapter.go
121 lines (97 loc) · 3.37 KB
/
adapter.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// Package google implements an adapter to extract metrics from google groupcache.
package google
import (
"github.com/golang/groupcache"
)
// Group implements interface GroupStatistics to extract metrics from google groupcache group.
type Group struct {
group *groupcache.Group
}
// New creates a new Group.
func New(group *groupcache.Group) *Group {
return &Group{group: group}
}
// Name returns the group's name
func (g *Group) Name() string {
return g.group.Name()
}
// Gets represents any Get request, including from peers
func (g *Group) Gets() int64 {
return g.group.Stats.Gets.Get()
}
// CacheHits represents either cache was good
func (g *Group) CacheHits() int64 {
return g.group.Stats.CacheHits.Get()
}
// GetFromPeersLatencyLower represents slowest duration to request value from peers
func (g *Group) GetFromPeersLatencyLower() int64 {
return 0
}
// PeerLoads represents either remote load or remote cache hit (not an error)
func (g *Group) PeerLoads() int64 {
return g.group.Stats.PeerLoads.Get()
}
// PeerErrors represents a count of errors from peers
func (g *Group) PeerErrors() int64 {
return g.group.Stats.PeerErrors.Get()
}
// Loads represents (gets - cacheHits)
func (g *Group) Loads() int64 {
return g.group.Stats.Loads.Get()
}
// LoadsDeduped represents after singleflight
func (g *Group) LoadsDeduped() int64 {
return g.group.Stats.LoadsDeduped.Get()
}
// LocalLoads represents total good local loads
func (g *Group) LocalLoads() int64 {
return g.group.Stats.LocalLoads.Get()
}
// LocalLoadErrs represents total bad local loads
func (g *Group) LocalLoadErrs() int64 {
return g.group.Stats.LocalLoadErrs.Get()
}
// ServerRequests represents gets that came over the network from peers
func (g *Group) ServerRequests() int64 {
return g.group.Stats.ServerRequests.Get()
}
// MainCacheItems represents number of items in the main cache
func (g *Group) MainCacheItems() int64 {
return g.group.CacheStats(groupcache.MainCache).Items
}
// MainCacheBytes represents number of bytes in the main cache
func (g *Group) MainCacheBytes() int64 {
return g.group.CacheStats(groupcache.MainCache).Bytes
}
// MainCacheGets represents number of get requests in the main cache
func (g *Group) MainCacheGets() int64 {
return g.group.CacheStats(groupcache.MainCache).Gets
}
// MainCacheHits represents number of hit in the main cache
func (g *Group) MainCacheHits() int64 {
return g.group.CacheStats(groupcache.MainCache).Hits
}
// MainCacheEvictions represents number of evictions in the main cache
func (g *Group) MainCacheEvictions() int64 {
return g.group.CacheStats(groupcache.MainCache).Evictions
}
// HotCacheItems represents number of items in the main cache
func (g *Group) HotCacheItems() int64 {
return g.group.CacheStats(groupcache.HotCache).Items
}
// HotCacheBytes represents number of bytes in the hot cache
func (g *Group) HotCacheBytes() int64 {
return g.group.CacheStats(groupcache.HotCache).Bytes
}
// HotCacheGets represents number of get requests in the hot cache
func (g *Group) HotCacheGets() int64 {
return g.group.CacheStats(groupcache.HotCache).Gets
}
// HotCacheHits represents number of hit in the hot cache
func (g *Group) HotCacheHits() int64 {
return g.group.CacheStats(groupcache.HotCache).Hits
}
// HotCacheEvictions represents number of evictions in the hot cache
func (g *Group) HotCacheEvictions() int64 {
return g.group.CacheStats(groupcache.HotCache).Evictions
}