31 Counter(
const std::string_view
name,
const std::string_view help)
43 core_->has_unit =
true;
55 void inc() const noexcept {
61 requires std::is_arithmetic_v<T>
62 void inc(T amount)
noexcept {
68 template <DimensionalValue V>
69 void inc(
const V& amount)
noexcept {
81 const auto [adapter, handle] = this->
bind();
87 lg->warn(
"counter '{}' dropping negative increment {}",
core_->name, nv.value);
94 adapter->inc(handle, nv.value);
A counter.
Definition counter.hpp:28
void inc(T amount) noexcept
Increment by a raw arithmetic amount (must be >= 0 and finite).
Definition counter.hpp:62
Counter(std::shared_ptr< MetricCore > core)
Internal: adopt a core prepared by a Registry or labels().
Definition counter.hpp:52
void inc() const noexcept
Increment by one.
Definition counter.hpp:55
Counter(const std::string_view name, const std::string_view help)
Standalone, unbound counter. Binds to the default adapter on first use.
Definition counter.hpp:31
void inc(const V &amount) noexcept
Increment by a dimensional amount; its unit is reconciled with the metric's declared/latched unit.
Definition counter.hpp:69
Counter labels(const Labels &dynamic) const noexcept
A same-type child series bound to dynamic labels (overlaid on the family's constant labels by the bac...
Definition counter.hpp:75
Counter(const CounterSpec &spec)
Standalone counter from a spec (unbound).
Definition counter.hpp:36
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
Counter 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
static spdlog::logger * logger() noexcept
The shared per-process metrics logger.
Definition metric_base.hpp:525
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
Declarative description of a counter, for Registry::counter / Counter::Counter.
Definition counter.hpp:17
std::string_view help
Definition counter.hpp:19
Labels labels
Definition counter.hpp:20
std::string_view name
Definition counter.hpp:18
comms::DisplayInfo display
Definition counter.hpp:22
Unit unit
Definition counter.hpp:21
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