@@ -41,13 +41,18 @@ type Counter interface {
41
41
// Add adds the given value to the counter. It panics if the value is <
42
42
// 0.
43
43
Add (float64 )
44
- // AddWithExemplar works like Add but also replaces the currently saved
45
- // exemplar (if any) with a new one, created from the provided value,
46
- // the current time as timestamp, and the provided labels. Empty Labels
47
- // will lead to a valid (label-less) exemplar. But if Labels is nil, the
48
- // current exemplar is left in place. This method panics if the value is
49
- // < 0, if any of the provided labels are invalid, or if the provided
50
- // labels contain more than 64 runes in total.
44
+ }
45
+
46
+ // ExemplarAdder is implemented by Counters that offer the option of adding a
47
+ // value to the Counter together with an exemplar. Its AddWithExemplar method
48
+ // works like the Add method of the Counter interface but also replaces the
49
+ // currently saved exemplar (if any) with a new one, created from the provided
50
+ // value, the current time as timestamp, and the provided labels. Empty Labels
51
+ // will lead to a valid (label-less) exemplar. But if Labels is nil, the current
52
+ // exemplar is left in place. AddWithExemplar panics if the value is < 0, if any
53
+ // of the provided labels are invalid, or if the provided labels contain more
54
+ // than 64 runes in total.
55
+ type ExemplarAdder interface {
51
56
AddWithExemplar (value float64 , exemplar Labels )
52
57
}
53
58
@@ -56,6 +61,9 @@ type CounterOpts Opts
56
61
57
62
// NewCounter creates a new Counter based on the provided CounterOpts.
58
63
//
64
+ // The returned implementation also implements ExemplarAdder. It is safe to
65
+ // perform the corresponding type assertion.
66
+ //
59
67
// The returned implementation tracks the counter value in two separate
60
68
// variables, a float64 and a uint64. The latter is used to track calls of the
61
69
// Inc method and calls of the Add method with a value that can be represented
0 commit comments