Skip to content
Open
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
21 changes: 21 additions & 0 deletions internal/metrics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package internal

// Counters is a trivial in-memory metrics registry for the demo service.
type Counters struct {
counts map[string]int
}

// NewCounters constructs an empty Counters.
func NewCounters() *Counters {
return &Counters{counts: make(map[string]int)}
}

// Incr increments the named counter by 1.
func (c *Counters) Incr(name string) {
c.counts[name]++
}

// Value returns the current value of the named counter.
func (c *Counters) Value(name string) int {
return c.counts[name]
}
Loading