-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathtimer_metrics.go
84 lines (64 loc) · 1.83 KB
/
timer_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
package gorelic
import (
metrics "github.com/yvasiyarov/go-metrics"
"time"
)
type baseTimerMetrica struct {
dataSource metrics.Timer
name string
units string
}
func (metrica *baseTimerMetrica) GetName() string {
return metrica.name
}
func (metrica *baseTimerMetrica) GetUnits() string {
return metrica.units
}
type timerRate1Metrica struct {
*baseTimerMetrica
}
func (metrica *timerRate1Metrica) GetValue() (float64, error) {
return metrica.dataSource.Rate1(), nil
}
type timerRateMeanMetrica struct {
*baseTimerMetrica
}
func (metrica *timerRateMeanMetrica) GetValue() (float64, error) {
return metrica.dataSource.RateMean(), nil
}
type timerMeanMetrica struct {
*baseTimerMetrica
}
func (metrica *timerMeanMetrica) GetValue() (float64, error) {
return metrica.dataSource.Mean() / float64(time.Millisecond), nil
}
type timerMinMetrica struct {
*baseTimerMetrica
}
func (metrica *timerMinMetrica) GetValue() (float64, error) {
return float64(metrica.dataSource.Min()) / float64(time.Millisecond), nil
}
type timerMaxMetrica struct {
*baseTimerMetrica
}
func (metrica *timerMaxMetrica) GetValue() (float64, error) {
return float64(metrica.dataSource.Max()) / float64(time.Millisecond), nil
}
type timerPercentile75Metrica struct {
*baseTimerMetrica
}
func (metrica *timerPercentile75Metrica) GetValue() (float64, error) {
return metrica.dataSource.Percentile(0.75) / float64(time.Millisecond), nil
}
type timerPercentile90Metrica struct {
*baseTimerMetrica
}
func (metrica *timerPercentile90Metrica) GetValue() (float64, error) {
return metrica.dataSource.Percentile(0.90) / float64(time.Millisecond), nil
}
type timerPercentile95Metrica struct {
*baseTimerMetrica
}
func (metrica *timerPercentile95Metrica) GetValue() (float64, error) {
return metrica.dataSource.Percentile(0.95) / float64(time.Millisecond), nil
}