Skip to content

Commit 126a256

Browse files
authored
Merge pull request #21 from ipfs/countervec2
Improve CounterVec abstraction
2 parents 0cef095 + 553507f commit 126a256

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

Diff for: interface.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ type Counter interface {
1212
Add(float64) // Only positive
1313
}
1414

15+
type Labels map[string]string
16+
1517
// CounterVec is a counter with tags.
1618
type CounterVec interface {
17-
IncWithLabelValues(labels ...string)
18-
AddWithLabelValues(n float64, labels ...string)
19+
With(Labels) Counter
1920
}
2021

2122
// Gauge is a metric that can be increased and decreased.

Diff for: noop.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,8 @@ func (g *noop) Observe(v float64) {
2727
// Noop
2828
}
2929

30-
func (g *noop) IncWithLabelValues(labels ...string) {
31-
// Noop
32-
}
33-
34-
func (g *noop) AddWithLabelValues(v float64, labels ...string) {
35-
// Noop
30+
func (g *noop) With(labels Labels) Counter {
31+
return g
3632
}
3733

3834
// Creator functions

Diff for: version.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "v0.1.0"
2+
"version": "v0.2.0"
33
}

0 commit comments

Comments
 (0)