26 Gauge(
const std::string_view
name,
const std::string_view help)
35 core_->has_unit =
true;
47 requires std::is_arithmetic_v<T>
48 void set(T value)
noexcept {
53 template <DimensionalValue V>
54 void set(
const V& value)
noexcept {
65 requires std::is_arithmetic_v<T>
66 void inc(T amount)
noexcept {
71 template <DimensionalValue V>
72 void inc(
const V& amount)
noexcept {
83 requires std::is_arithmetic_v<T>
84 void dec(T amount)
noexcept {
89 template <DimensionalValue V>
90 void dec(
const V& amount)
noexcept {
101 void apply(
const Op op,
const NormalizedValue& nv,
const std::string_view
name)
const noexcept {
102 const auto [adapter, handle] = this->
bind();
109 ((*adapter).*op)(handle, nv.value);
The pluggable backend.
Definition adapter.hpp:62
virtual void dec(const MetricHandle &handle, double amount) noexcept=0
Decrease the series behind handle by amount (gauge).
virtual void inc(const MetricHandle &handle, double amount) noexcept=0
Increase the series behind handle by amount (counter/gauge).
virtual void set(const MetricHandle &handle, double value) noexcept=0
Set the series behind handle to value (gauge/untyped).
A gauge.
Definition gauge.hpp:24
void inc(T amount) noexcept
Increment by a raw amount.
Definition gauge.hpp:66
void dec(const V &amount) noexcept
Decrement by a dimensional amount.
Definition gauge.hpp:90
Gauge(const std::string_view name, const std::string_view help)
Definition gauge.hpp:26
Gauge(const GaugeSpec &spec)
Definition gauge.hpp:29
void dec(T amount) noexcept
Decrement by a raw amount.
Definition gauge.hpp:84
void inc() noexcept
Increment by one.
Definition gauge.hpp:59
Gauge labels(const Labels &dynamic) const noexcept
Definition gauge.hpp:94
Gauge(std::shared_ptr< MetricCore > core)
Definition gauge.hpp:43
void set(T value) noexcept
Set the gauge to a raw value.
Definition gauge.hpp:48
void inc(const V &amount) noexcept
Increment by a dimensional amount.
Definition gauge.hpp:72
void dec() noexcept
Decrement by one.
Definition gauge.hpp:77
void set(const V &value) noexcept
Set the gauge to a dimensional value.
Definition gauge.hpp:54
An immutable-by-convention set of labels, kept sorted by name with duplicates collapsed last-wins.
Definition labels.hpp:55
CRTP base shared by every metric type.
Definition metric_base.hpp:377
Gauge make_child(const Labels &dynamic) const noexcept
Resolve a labeled child of the same metric type.
Definition metric_base.hpp:458
bool reconcile_unit(const Unit &observed, Adapter &adapter) const noexcept
Reconcile an observed unit against the family's known unit.
Definition metric_base.hpp:475
std::string_view name() const noexcept
The metric's fully-qualified name.
Definition metric_base.hpp:380
const std::shared_ptr< MetricCore > & core() const noexcept
Definition metric_base.hpp:449
bool check_finite(const double value, std::string_view op) const noexcept
Drop-and-log guard for a non-finite sample.
Definition metric_base.hpp:514
std::shared_ptr< MetricCore > core_
Definition metric_base.hpp:530
Binding bind() const noexcept
Resolve the adapter and backend handle this metric should record against.
Definition metric_base.hpp:435
MetricCore (the shared per-series state) and the CRTP MetricBase that gives every metric type value s...
Definition adapter.hpp:24
NormalizedValue normalize(const V &value)
Reduce a dimval value to a NormalizedValue.
Definition dimval.hpp:47
MetricType
The OpenMetrics / Prometheus metric kinds prom understands.
Definition unit.hpp:15
std::shared_ptr< MetricState > MetricHandle
Opaque, backend-owned handle to a registered metric family or a labeled child series.
Definition fwd.hpp:34
Declarative description of a gauge.
Definition gauge.hpp:14
comms::DisplayInfo display
Definition gauge.hpp:19
Unit unit
Definition gauge.hpp:18
std::string_view name
Definition gauge.hpp:15
Labels labels
Definition gauge.hpp:17
std::string_view help
Definition gauge.hpp:16
A plain magnitude paired with the unit it was carrying (empty for raw arithmetic).
Definition dimval.hpp:36
OpenMetrics unit suffix plus optional dimensional metadata.
Definition unit.hpp:53
std::string_view kind
Dimensional compatibility group (e.g. "time").
Definition unit.hpp:55
bool from_dimval
True when inferred from a dimval value.
Definition unit.hpp:57
std::string_view name
Human-readable unit name (e.g. "seconds").
Definition unit.hpp:54
constexpr bool empty() const noexcept
A unit carries no information when it has neither a name nor a kind.
Definition unit.hpp:60
std::string_view symbol
Display symbol (e.g. "s").
Definition unit.hpp:56