-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtracker.go
37 lines (29 loc) · 1.16 KB
/
tracker.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
package stats
import "context"
// Tracker defines stats collector.
type Tracker interface {
Adder
Setter
}
// Adder defines incremental metric collector.
type Adder interface {
// Add collects additional or observable value.
Add(ctx context.Context, name string, increment float64, labelsAndValues ...string)
}
// AdderFunc implements Adder.
type AdderFunc func(ctx context.Context, name string, increment float64, labelsAndValues ...string)
// Add collects additional or observable value.
func (f AdderFunc) Add(ctx context.Context, name string, increment float64, labelsAndValues ...string) {
f(ctx, name, increment, labelsAndValues...)
}
// Setter defines absolute value collector.
type Setter interface {
// Set collects absolute value, e.g. number of goroutines.
Set(ctx context.Context, name string, absolute float64, labelsAndValues ...string)
}
// SetterFunc implements Setter.
type SetterFunc func(ctx context.Context, name string, absolute float64, labelsAndValues ...string)
// Set collects absolute value.
func (f SetterFunc) Set(ctx context.Context, name string, absolute float64, labelsAndValues ...string) {
f(ctx, name, absolute, labelsAndValues...)
}