diff --git a/internal/metrics.go b/internal/metrics.go new file mode 100644 index 0000000..f826704 --- /dev/null +++ b/internal/metrics.go @@ -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] +}