-
Notifications
You must be signed in to change notification settings - Fork 0
/
metrics.go
34 lines (27 loc) · 923 Bytes
/
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
package metrics
import "time"
// Identifier holds the name and type of a single metric.
type Identifier[V valueType] struct {
mt metricType[V]
name string
}
func new[V valueType](name string, mt metricType[V]) Identifier[V] {
return Identifier[V]{mt: mt, name: name}
}
// CountMetric creates a metric [Identifier] for a count metric.
func CountMetric(name string) Identifier[int32] {
return new(name, count)
}
// GaugeMetric creates a metric [Identifier] for a gauge metric.
func GaugeMetric(name string) Identifier[float32] {
return new(name, gauge)
}
// DistributionMetric creates a metric [Identifier] for a distribution metric.
func DistributionMetric(name string) Identifier[float32] {
return new(name, distribution)
}
// TimingMetric creates a metric [Identifier] for a distribution metric that
// captures timing.
func TimingMetric(name string) Identifier[time.Duration] {
return new(name, timing)
}