Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
CounterVec: even more ergonomic
  • Loading branch information
hsanjuan committed Feb 19, 2025
commit 1534fc53828b146b83c9721f81317d3ded6f68ac
6 changes: 2 additions & 4 deletions interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ type Counter interface {
Add(float64) // Only positive
}

type Labels map[string]string

// CounterVec is a counter with tags.
type CounterVec interface {
With(Labels) Counter
WithLabelValues(lvs ...string) Counter
}

// Gauge is a metric that can be increased and decreased.
Expand Down Expand Up @@ -48,7 +46,7 @@ type SummaryOpts struct {
// Creator can be used to create different types of metrics.
type Creator interface {
Counter() Counter
CounterVec() CounterVec
CounterVec(labelNames []string) CounterVec
Gauge() Gauge
Histogram(buckets []float64) Histogram

Expand Down
4 changes: 2 additions & 2 deletions noop.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (g *noop) Observe(v float64) {
// Noop
}

func (g *noop) With(labels Labels) Counter {
func (g *noop) WithLabelValues(lvs ...string) Counter {
return g
}

Expand All @@ -37,7 +37,7 @@ func (g *noop) Counter() Counter {
return g
}

func (g *noop) CounterVec() CounterVec {
func (g *noop) CounterVec(lvs []string) CounterVec {
return g
}

Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "v0.2.0"
"version": "v0.3.0"
}