| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | package metrix |
| 4 | |
| 5 | // SeededGauge declares a stateful gauge and seeds it with zero immediately. |
| 6 | func SeededGauge(m StatefulMeter, name string, opts ...InstrumentOption) StatefulGauge { |
| 7 | g := m.Gauge(name, opts...) |
| 8 | g.Set(0) |
| 9 | return g |
| 10 | } |
| 11 | |
| 12 | // SeededCounter declares a stateful counter and seeds it with zero immediately. |
| 13 | // |
| 14 | // Note: Add(0) advances per-series counter sequence bookkeeping, which is |
| 15 | // harmless for value semantics and ensures a visible committed zero series. |
| 16 | func SeededCounter(m StatefulMeter, name string, opts ...InstrumentOption) StatefulCounter { |
| 17 | c := m.Counter(name, opts...) |
| 18 | c.Add(0) |
| 19 | return c |
| 20 | } |