Skip to content

Commit 1534fc5

Browse files
committed
CounterVec: even more ergonomic
1 parent 126a256 commit 1534fc5

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

interface.go

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

15-
type Labels map[string]string
16-
1715
// CounterVec is a counter with tags.
1816
type CounterVec interface {
19-
With(Labels) Counter
17+
WithLabelValues(lvs ...string) Counter
2018
}
2119

2220
// Gauge is a metric that can be increased and decreased.
@@ -48,7 +46,7 @@ type SummaryOpts struct {
4846
// Creator can be used to create different types of metrics.
4947
type Creator interface {
5048
Counter() Counter
51-
CounterVec() CounterVec
49+
CounterVec(labelNames []string) CounterVec
5250
Gauge() Gauge
5351
Histogram(buckets []float64) Histogram
5452

noop.go

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

30-
func (g *noop) With(labels Labels) Counter {
30+
func (g *noop) WithLabelValues(lvs ...string) Counter {
3131
return g
3232
}
3333

@@ -37,7 +37,7 @@ func (g *noop) Counter() Counter {
3737
return g
3838
}
3939

40-
func (g *noop) CounterVec() CounterVec {
40+
func (g *noop) CounterVec(lvs []string) CounterVec {
4141
return g
4242
}
4343

version.json

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

0 commit comments

Comments
 (0)