forked from go-kit/kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
metrics.go
51 lines (45 loc) · 1.37 KB
/
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
package metrics
// Counter is a monotonically-increasing, unsigned, 64-bit integer used to
// capture the number of times an event has occurred. By tracking the deltas
// between measurements of a counter over intervals of time, an aggregation
// layer can derive rates, acceleration, etc.
type Counter interface {
Name() string
With(Field) Counter
Add(delta uint64)
}
// Gauge captures instantaneous measurements of something using signed, 64-bit
// floats. The value does not need to be monotonic.
type Gauge interface {
Name() string
With(Field) Gauge
Set(value float64)
Add(delta float64)
Get() float64
}
// Histogram tracks the distribution of a stream of values (e.g. the number of
// milliseconds it takes to handle requests). Implementations may choose to
// add gauges for values at meaningful quantiles.
type Histogram interface {
Name() string
With(Field) Histogram
Observe(value int64)
Distribution() ([]Bucket, []Quantile)
}
// Field is a key/value pair associated with an observation for a specific
// metric. Fields may be ignored by implementations.
type Field struct {
Key string
Value string
}
// Bucket is a range in a histogram which aggregates observations.
type Bucket struct {
From int64
To int64
Count int64
}
// Quantile is a pair of quantile (0..100) and its observed maximum value.
type Quantile struct {
Quantile int // 0..100
Value int64
}