-
Notifications
You must be signed in to change notification settings - Fork 8
/
stats.go
36 lines (30 loc) · 894 Bytes
/
stats.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
package bcache
import (
"time"
)
func statsError(oper string, buck []byte) {
go statsIncrement(
"bolt.query.error",
map[string]string{"bucket": string(buck), "operation": oper},
)
}
func statsSuccess(oper string, buck []byte, d time.Duration) {
go statsIncrement("bolt.query", map[string]string{"bucket": string(buck), "operation": oper})
go statsValueAdd(
"bolt.query.duration",
map[string]string{"bucket": string(buck), "operation": oper},
float64(d.Nanoseconds())/float64(time.Millisecond),
)
}
func statsNotFound(buck []byte) {
go statsIncrement(
"bolt.query.not_found",
map[string]string{"bucket": string(buck)},
)
}
func statsIncrement(metric string, tags map[string]string) {
stats.Increment("bcache/persistence", metric, tags)
}
func statsValueAdd(metric string, tags map[string]string, v float64) {
stats.ValueAdd("bcache/persistence", metric, tags, v)
}