-
Notifications
You must be signed in to change notification settings - Fork 4
/
timing_simple.go
44 lines (34 loc) · 990 Bytes
/
timing_simple.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
package metrics
import (
"time"
)
type MetricTimingSimple struct {
commonAggregativeSimple
}
func (r *Registry) newMetricTimingSimple(key string, tags AnyTags) *MetricTimingSimple {
metric := metricTimingSimplePool.Get().(*MetricTimingSimple)
metric.init(r, key, tags)
return metric
}
func (m *MetricTimingSimple) init(r *Registry, key string, tags AnyTags) {
m.commonAggregativeSimple.init(r, m, key, tags)
}
func TimingSimple(key string, tags AnyTags) *MetricTimingSimple {
return registry.TimingSimple(key, tags)
}
func (r *Registry) TimingSimple(key string, tags AnyTags) *MetricTimingSimple {
if IsDisabled() {
return (*MetricTimingSimple)(nil)
}
m := r.Get(TypeTimingSimple, key, tags)
if m != nil {
return m.(*MetricTimingSimple)
}
return r.newMetricTimingSimple(key, tags)
}
func (m *MetricTimingSimple) ConsiderValue(v time.Duration) {
m.considerValue(float64(v.Nanoseconds()))
}
func (m *MetricTimingSimple) GetType() Type {
return TypeTimingSimple
}