// StatSource creates metrics with the given name. The returned metrics should be // concurrency-safe. type StatSource interface { Timer(name string) Timer Counter(name string) Counter } // Timer emits the duration of a particular event. The duration value is // typically used to measure latencies and create histograms thereof. type Timer func(duration time.Duration) // Counter emits any number of events happening at a given time. For example, // Counters are often used to measure RPS. type Counter func(delta int) // A StatSet is the cached value. type statSet struct { // Latency measures how long an Action takes Latency Timer // Success is incremented when an Action does not return an error Success Counter // Error is incremented when an Action results in an error Error Counter } // Cache describes a read-through cache to obtain type statCache interface { // get returns a shared statSet for the given name, either from the cache or // a provided StatSource. get(name string) *statSet }