|
prom 0.1.0
Client-independent C++23 Prometheus/OpenMetrics metric abstraction
|
CRTP base shared by every metric type. More...
#include <metric_base.hpp>

Classes | |
| struct | Binding |
A resolved (adapter, handle) snapshot — the result of bind(). More... | |
Public Member Functions | |
| std::string_view | name () const noexcept |
| The metric's fully-qualified name. | |
| MetricType | type () const noexcept |
| The metric kind. | |
Protected Member Functions | |
| MetricBase (const MetricType type, const std::string_view name, const std::string_view help) | |
| Standalone, unbound construction from a name and help string. | |
| MetricBase (std::shared_ptr< MetricCore > core) | |
| Adopt an already-populated core (registered metrics and children). | |
| MetricBase (const MetricBase &)=default | |
| MetricBase & | operator= (const MetricBase &)=default |
| MetricBase (MetricBase &&)=default | |
| MetricBase & | operator= (MetricBase &&)=default |
| ~MetricBase ()=default | |
| Binding | bind () const noexcept |
| Resolve the adapter and backend handle this metric should record against. | |
| const std::shared_ptr< MetricCore > & | core () const noexcept |
| Derived | make_child (const Labels &dynamic) const noexcept |
| Resolve a labeled child of the same metric type. | |
| bool | reconcile_unit (const Unit &observed, Adapter &adapter) const noexcept |
| Reconcile an observed unit against the family's known unit. | |
| bool | check_finite (const double value, std::string_view op) const noexcept |
| Drop-and-log guard for a non-finite sample. | |
Static Protected Member Functions | |
| static spdlog::logger * | logger () noexcept |
| The shared per-process metrics logger. | |
Protected Attributes | |
| std::shared_ptr< MetricCore > | core_ |
CRTP base shared by every metric type.
Provides the binding machinery and the protected helpers (record_*, make_child, reconcile_unit) the concrete types build their public surface from.
|
inlineprotected |
Standalone, unbound construction from a name and help string.
Reads its adapter from the process-wide cell and binds lazily on first use. It also follows the process-wide global decoration, so a prefix / labels installed via Registry::global() reach standalone metrics too; with the default (empty) decoration the effective name and labels are unchanged.
|
inlineexplicitprotected |
Adopt an already-populated core (registered metrics and children).
|
protecteddefault |
|
protecteddefault |
|
protecteddefault |
|
inlineprotectednoexcept |
Resolve the adapter and backend handle this metric should record against.
Fast path: load the published binding. A pinned binding (a labeled child) is returned as-is — children never migrate. Otherwise the binding is reused while it matches the source's adapter version() and, for a scoped metric, the scope's config version().
Slow path (rebind): resolve the current adapter from the source, recompute the name / labels / display from the live scope (if scoped), register the family, and publish a fresh binding. This fires on first use of a standalone/scoped metric, on an adapter swap (live migration to the new backend — the previous backend's series are left behind), and on a scope reconfiguration.
|
inlineprotectednoexcept |
Drop-and-log guard for a non-finite sample.
Returns true when the value is safe to record.
|
inlineprotectednoexcept |
|
inlinestaticprotectednoexcept |
The shared per-process metrics logger.
|
inlineprotectednoexcept |
Resolve a labeled child of the same metric type.
The child carries the backend's resolved child handle and points back at this family for unit reconciliation. The child is pinned: it snapshots the adapter and the scope-decorated state in effect at the time of the labels() call and never migrates, even if the source adapter or scope later changes.
|
inlinenoexcept |
The metric's fully-qualified name.
|
protecteddefault |
|
protecteddefault |
|
inlineprotectednoexcept |
Reconcile an observed unit against the family's known unit.
Returns false (and logs) when a dimensional sample's kind contradicts the latched kind, signalling the caller to drop the sample. A unitless sample always passes. The first dimensional sample latches the unit.
|
inlinenoexcept |
The metric kind.
|
protected |