-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtiming_flow.go
44 lines (34 loc) · 950 Bytes
/
timing_flow.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 MetricTimingFlow struct {
commonAggregativeFlow
}
func (r *Registry) newMetricTimingFlow(key string, tags AnyTags) *MetricTimingFlow {
metric := metricTimingFlowPool.Get().(*MetricTimingFlow)
metric.init(r, key, tags)
return metric
}
func (m *MetricTimingFlow) init(r *Registry, key string, tags AnyTags) {
m.commonAggregativeFlow.init(r, m, key, tags)
}
func TimingFlow(key string, tags AnyTags) *MetricTimingFlow {
return registry.TimingFlow(key, tags)
}
func (r *Registry) TimingFlow(key string, tags AnyTags) *MetricTimingFlow {
if IsDisabled() {
return (*MetricTimingFlow)(nil)
}
m := r.Get(TypeTimingFlow, key, tags)
if m != nil {
return m.(*MetricTimingFlow)
}
return r.newMetricTimingFlow(key, tags)
}
func (m *MetricTimingFlow) ConsiderValue(v time.Duration) {
m.considerValue(float64(v.Nanoseconds()))
}
func (m *MetricTimingFlow) GetType() Type {
return TypeTimingFlow
}