18#include <commons/display_info.hpp>
40 std::span<const std::string>
states{};
72 [[nodiscard]]
virtual std::string_view
backend_name() const noexcept = 0;
82 const
Labels& dynamic) noexcept = 0;
124 [[nodiscard]]
virtual std::uint64_t
version() const noexcept = 0;
The source a metric reads its current adapter from, decoupled from Registry so that metric_base can r...
Definition adapter.hpp:114
virtual ~AdapterSource()=default
virtual AdapterPtr adapter() const =0
The current adapter, never null.
AdapterSource & operator=(const AdapterSource &)=delete
AdapterSource(AdapterSource &&)=delete
virtual std::uint64_t version() const noexcept=0
Monotonic counter, bumped on every adapter swap.
AdapterSource & operator=(AdapterSource &&)=delete
AdapterSource(const AdapterSource &)=delete
The pluggable backend.
Definition adapter.hpp:62
virtual ~Adapter()=default
virtual void set_unit(const MetricHandle &, const Unit &) noexcept
Late unit inference hook.
Definition adapter.hpp:102
Adapter & operator=(const Adapter &)=delete
virtual void observe(const MetricHandle &handle, double value) noexcept=0
Record an observation against handle (histogram/summary).
virtual void set_info(const MetricHandle &handle, std::span< const Label > labels) noexcept=0
Replace the label set carried by an info metric.
Adapter & operator=(Adapter &&)=delete
virtual void dec(const MetricHandle &handle, double amount) noexcept=0
Decrease the series behind handle by amount (gauge).
Adapter(const Adapter &)=delete
virtual std::string_view backend_name() const noexcept=0
Stable identifier of the backend (e.g. "null", "prometheus-cpp").
virtual MetricHandle resolve(const MetricHandle &family, const Labels &dynamic) noexcept=0
Resolve the labeled child of family for the given dynamic labels, creating it on first request.
virtual MetricHandle register_metric(const MetricMeta &meta) noexcept=0
Register a metric family.
virtual void set_state(const MetricHandle &handle, std::string_view state, bool active) noexcept=0
Set the boolean value of one member of a state set.
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).
Adapter(Adapter &&)=delete
An immutable-by-convention set of labels, kept sorted by name with duplicates collapsed last-wins.
Definition labels.hpp:55
Opaque backend state for a registered family or a labeled child.
Definition adapter.hpp:46
MetricState & operator=(MetricState &&)=default
virtual ~MetricState()=default
MetricState & operator=(const MetricState &)=default
MetricState(MetricState &&)=default
MetricState(const MetricState &)=default
Forward declarations and shared_ptr aliases for the prom public API.
Label vocabulary: Label, the sorted/deduped Labels set, name validation, and an std::hash<Labels> spe...
Definition adapter.hpp:24
MetricType
The OpenMetrics / Prometheus metric kinds prom understands.
Definition unit.hpp:15
std::shared_ptr< Adapter > AdapterPtr
Shared ownership of an Adapter.
Definition fwd.hpp:38
std::shared_ptr< MetricState > MetricHandle
Opaque, backend-owned handle to a registered metric family or a labeled child series.
Definition fwd.hpp:34
A single name="value" label pair.
Definition labels.hpp:20
OpenMetrics unit suffix plus optional dimensional metadata.
Definition unit.hpp:53
Metric kinds (MetricType) and the OpenMetrics Unit descriptor.