Skip to content

Commit

Permalink
Merge pull request #22 from ipfs/countervec3
Browse files Browse the repository at this point in the history
CounterVec: even more ergonomic
  • Loading branch information
hsanjuan authored Feb 19, 2025
2 parents 126a256 + 1534fc5 commit c39372e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
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"
}

0 comments on commit c39372e

Please sign in to comment.