From 6bf03617e072a0ab4872a2e6f03595dea98b73ed Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Wed, 27 Nov 2024 02:00:52 +0100 Subject: [PATCH] metrics: docs --- metrics/counter.go | 3 +-- metrics/counter_float64.go | 2 +- metrics/ewma.go | 5 ++--- metrics/gauge.go | 2 +- metrics/gauge_float64.go | 2 +- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/metrics/counter.go b/metrics/counter.go index 535641232f..0f373b0d92 100644 --- a/metrics/counter.go +++ b/metrics/counter.go @@ -34,8 +34,7 @@ type CounterSnapshot int64 // Count returns the count at the time the snapshot was taken. func (c CounterSnapshot) Count() int64 { return int64(c) } -// Counter is the standard implementation of a Counter and uses the -// sync/atomic package to manage a single int64 value. +// Counter hold an int64 value that can be incremented and decremented. type Counter atomic.Int64 // Clear sets the counter to zero. diff --git a/metrics/counter_float64.go b/metrics/counter_float64.go index 9a7b6a93c8..91c4215c4d 100644 --- a/metrics/counter_float64.go +++ b/metrics/counter_float64.go @@ -35,7 +35,7 @@ type CounterFloat64Snapshot float64 // Count returns the value at the time the snapshot was taken. func (c CounterFloat64Snapshot) Count() float64 { return float64(c) } -// CounterFloat64 is the uses atomic to manage a single float64 value. +// CounterFloat64 holds a float64 value that can be incremented and decremented. type CounterFloat64 atomic.Uint64 // Clear sets the counter to zero. diff --git a/metrics/ewma.go b/metrics/ewma.go index 504679ba77..5746d6df8e 100644 --- a/metrics/ewma.go +++ b/metrics/ewma.go @@ -34,9 +34,8 @@ func NewEWMA15() *EWMA { return NewEWMA(1 - math.Exp(-5.0/60.0/15)) } -// EWMA imlements an exponential weighted moving average. It tracks the number -// of uncounted events and processes them on each tick. It uses the -// sync/atomic package to manage uncounted events. +// EWMA continuously calculate an exponentially-weighted moving average +// based on an outside source of clock ticks. type EWMA struct { uncounted atomic.Int64 alpha float64 diff --git a/metrics/gauge.go b/metrics/gauge.go index 07c0b93c51..ba7843e03b 100644 --- a/metrics/gauge.go +++ b/metrics/gauge.go @@ -32,7 +32,7 @@ func NewRegisteredGauge(name string, r Registry) *Gauge { return c } -// Gauge and uses the sync/atomic package to manage a single int64 value. +// Gauge holds an int64 value that can be set arbitrarily. type Gauge atomic.Int64 // Snapshot returns a read-only copy of the gauge. diff --git a/metrics/gauge_float64.go b/metrics/gauge_float64.go index 94d6ab7784..05b401ef9c 100644 --- a/metrics/gauge_float64.go +++ b/metrics/gauge_float64.go @@ -35,7 +35,7 @@ func NewRegisteredGaugeFloat64(name string, r Registry) *GaugeFloat64 { return c } -// GaugeFloat64 and uses atomic to manage a single float64 value. +// GaugeFloat64 hold a float64 value that can be set arbitrarily. type GaugeFloat64 atomic.Uint64 // Snapshot returns a read-only copy of the gauge.