|
prom 0.1.0
Client-independent C++23 Prometheus/OpenMetrics metric abstraction
|
Namespaces | |
| namespace | detail |
Portable atomic shared_ptr<const T> exposing just load()/store(). | |
| namespace | prometheus_cpp |
Classes | |
| class | Adapter |
| The pluggable backend. More... | |
| class | AdapterCell |
| A swappable adapter slot shared by every metric that reads from it. More... | |
| class | AdapterSource |
The source a metric reads its current adapter from, decoupled from Registry so that metric_base can resolve a binding without depending on the registry layer (which would be an include cycle), mirroring ScopeState. More... | |
| class | CompositeAdapter |
| A backend that forwards every call to a fixed set of child adapters. More... | |
| class | CompositeState |
| Backend state for a composite family or child: the index-aligned bundle of the handles each wrapped adapter returned. More... | |
| class | Counter |
| A counter. More... | |
| struct | CounterSpec |
Declarative description of a counter, for Registry::counter / Counter::Counter. More... | |
| struct | Error |
| A validation failure: a machine code plus a human message. More... | |
| class | Exception |
Thrown by the throwing Registry factories when a spec fails validation. More... | |
| class | Gauge |
| A gauge. More... | |
| struct | GaugeSpec |
| Declarative description of a gauge. More... | |
| class | Histogram |
| A histogram. More... | |
| struct | HistogramSpec |
| Declarative description of a histogram. More... | |
| class | Info |
| An info metric: a single sample whose labels carry the payload (build version, commit, ...). More... | |
| struct | InfoSpec |
| Declarative description of an info metric. More... | |
| struct | Label |
A single name="value" label pair. More... | |
| class | Labels |
| An immutable-by-convention set of labels, kept sorted by name with duplicates collapsed last-wins. More... | |
| class | MetricBase |
| CRTP base shared by every metric type. More... | |
| struct | MetricCore |
| Shared, reference-counted state behind every metric handle. More... | |
| struct | MetricInfo |
A read-only snapshot describing one registered metric, returned by the enumeration APIs (Registry::metrics, Scope::metrics). More... | |
| struct | MetricMeta |
The complete, backend-agnostic description of a metric family handed to Adapter::register_metric. More... | |
| class | MetricState |
| Opaque backend state for a registered family or a labeled child. More... | |
| struct | NormalizedValue |
| A plain magnitude paired with the unit it was carrying (empty for raw arithmetic). More... | |
| class | NullAdapter |
| A backend that records nothing. More... | |
| class | Registry |
| Creates registered metrics against a single adapter cell. More... | |
| struct | RegistryConfig |
The decoration a Registry applies to every metric created through it: a name prefix, default constant labels, and default display metadata. More... | |
| class | Scope |
| A named, reconfigurable metrics instance for one library. More... | |
| struct | ScopeConfig |
The configuration a Scope applies to every metric created through it. More... | |
| class | ScopeState |
| Read-only view a scoped metric uses to re-resolve its name, constant labels, and display metadata against the live scope configuration on every use. More... | |
| class | StateSet |
| A state set: each declared state is a boolean, exposed as one series per state with value 0 or 1. More... | |
| struct | StateSetSpec |
| Declarative description of a state set. More... | |
| class | Summary |
| A summary. Like a histogram but tracks quantiles instead of fixed buckets. More... | |
| struct | SummarySpec |
| Declarative description of a summary. More... | |
| struct | Unit |
| OpenMetrics unit suffix plus optional dimensional metadata. More... | |
| class | Untyped |
| An untyped metric: just a settable value. More... | |
| struct | UntypedSpec |
| Declarative description of an untyped metric. More... | |
Concepts | |
| concept | DimensionalValue |
Satisfied by a dimval-like value: it exposes a value_t, reports its magnitude through numeric_as_double(), and carries unit metadata through either unit_descriptor() (measures) or descriptor() (units). | |
Typedefs | |
| template<class T > | |
| using | expected = std::expected< T, Error > |
std::expected<T, Error> — the result type of the Registry::try_* family. | |
| using | MetricHandle = std::shared_ptr< MetricState > |
| Opaque, backend-owned handle to a registered metric family or a labeled child series. | |
| using | AdapterPtr = std::shared_ptr< Adapter > |
Shared ownership of an Adapter. | |
Enumerations | |
| enum class | ErrorCode : std::uint8_t { InvalidMetricName , InvalidLabelName , EmptyHelp , InvalidBuckets , InvalidQuantiles , EmptyStateSet , RegistrationFailed } |
| Why a metric definition or registration was rejected. More... | |
| enum class | MetricType : std::uint8_t { Counter , Gauge , Histogram , Summary , Untyped , Info , StateSet } |
| The OpenMetrics / Prometheus metric kinds prom understands. More... | |
Functions | |
| template<DimensionalValue V> | |
| NormalizedValue | normalize (const V &value) |
Reduce a dimval value to a NormalizedValue. | |
| template<class T > requires std::is_arithmetic_v<T> | |
| NormalizedValue | normalize (T value) noexcept |
| Pass an arithmetic sample straight through with no unit attached. | |
| constexpr std::string_view | to_string (const ErrorCode code) noexcept |
Human-readable spelling of an ErrorCode. | |
| constexpr bool | is_valid_metric_name (std::string_view name) noexcept |
A metric name is valid when it matches Prometheus's [a-zA-Z_][a-zA-Z0-9_]*. | |
| constexpr bool | is_valid_label_name (const std::string_view name) noexcept |
A label name follows the metric-name charset but additionally rejects the __ prefix, which OpenMetrics reserves for internal use. | |
| MetricInfo | describe (const MetricCore &core) |
Build a MetricInfo from a core, applying scope decoration for a scoped metric's effective name and constant labels. | |
| Counter | counter (const CounterSpec &spec) |
| Gauge | gauge (const GaugeSpec &spec) |
| Histogram | histogram (const HistogramSpec &spec) |
| Summary | summary (const SummarySpec &spec) |
| Untyped | untyped (const UntypedSpec &spec) |
| Info | info (const InfoSpec &spec) |
| StateSet | stateset (const StateSetSpec &spec) |
| expected< Counter > | try_counter (const CounterSpec &spec) noexcept |
| expected< Gauge > | try_gauge (const GaugeSpec &spec) noexcept |
| expected< Histogram > | try_histogram (const HistogramSpec &spec) noexcept |
| expected< Summary > | try_summary (const SummarySpec &spec) noexcept |
| expected< Untyped > | try_untyped (const UntypedSpec &spec) noexcept |
| expected< Info > | try_info (const InfoSpec &spec) noexcept |
| expected< StateSet > | try_stateset (const StateSetSpec &spec) noexcept |
| std::shared_ptr< Scope > | scope (const std::string_view name, ScopeConfig config) |
Get-or-create the process-wide scope named name, using config only if it does not yet exist (a later call returns the existing scope and ignores config — reconfigure through the returned scope's setters instead). | |
| std::shared_ptr< Scope > | scope (const std::string_view name) |
Get-or-create the scope named name with a default config whose prefix is name + "_". | |
| std::shared_ptr< Scope > | find_scope (const std::string_view name) |
Return the scope named name, or nullptr if none has been created. | |
| std::vector< std::shared_ptr< Scope > > | scopes () |
| Every process-wide scope created so far (unordered). | |
| std::vector< std::string > | scope_names () |
| The names of every process-wide scope created so far (unordered). | |
| constexpr std::string_view | to_string (const MetricType type) noexcept |
Lower-case OpenMetrics spelling of a MetricType (e.g. "counter"). | |
Variables | |
| constexpr std::array< double, 11 > | default_histogram_buckets |
The default bucket bounds applied when a histogram spec leaves buckets empty — the canonical Prometheus client default set (seconds-oriented). | |
| constexpr std::array< double, 3 > | default_summary_quantiles = {0.5, 0.9, 0.99} |
Default quantiles applied when a summary spec leaves quantiles empty. | |
| using prom::AdapterPtr = typedef std::shared_ptr<Adapter> |
| using prom::expected = typedef std::expected<T, Error> |
std::expected<T, Error> — the result type of the Registry::try_* family.
| using prom::MetricHandle = typedef std::shared_ptr<MetricState> |
Opaque, backend-owned handle to a registered metric family or a labeled child series.
Always non-null once handed back by an Adapter.
|
strong |
Why a metric definition or registration was rejected.
| Enumerator | |
|---|---|
| InvalidMetricName | Name violates |
| InvalidLabelName | A label name is invalid or uses the reserved |
| EmptyHelp | Help text is required but was empty. |
| InvalidBuckets | Histogram buckets are unsorted, empty, or non-finite. |
| InvalidQuantiles | Summary quantiles fall outside the open interval (0, 1). |
| EmptyStateSet | A state set was declared with no states. |
| RegistrationFailed | The backend refused to register the metric. |
|
strong |
The OpenMetrics / Prometheus metric kinds prom understands.
The numeric values are stable and intended for cheap switch dispatch inside adapters; do not rely on them crossing an ABI boundary.
|
inline |
|
inline |
Build a MetricInfo from a core, applying scope decoration for a scoped metric's effective name and constant labels.
|
inline |
Return the scope named name, or nullptr if none has been created.
|
inline |
|
constexprnoexcept |
A label name follows the metric-name charset but additionally rejects the __ prefix, which OpenMetrics reserves for internal use.
|
constexprnoexcept |
A metric name is valid when it matches Prometheus's [a-zA-Z_][a-zA-Z0-9_]*.
| NormalizedValue prom::normalize | ( | const V & | value | ) |
Reduce a dimval value to a NormalizedValue.
Measures expose both descriptor() (the measure descriptor) and unit_descriptor() (the base unit); units expose only descriptor() (which already is a unit descriptor). Either way we want the unit descriptor's long_name, kind, and symbol, so prefer unit_descriptor() when present.
|
noexcept |
Pass an arithmetic sample straight through with no unit attached.
|
inline |
Get-or-create the scope named name with a default config whose prefix is name + "_".
|
inline |
Get-or-create the process-wide scope named name, using config only if it does not yet exist (a later call returns the existing scope and ignores config — reconfigure through the returned scope's setters instead).
|
inline |
The names of every process-wide scope created so far (unordered).
|
inline |
Every process-wide scope created so far (unordered).
|
inline |
|
inline |
|
constexprnoexcept |
Human-readable spelling of an ErrorCode.
|
constexprnoexcept |
Lower-case OpenMetrics spelling of a MetricType (e.g. "counter").
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inlineconstexpr |
The default bucket bounds applied when a histogram spec leaves buckets empty — the canonical Prometheus client default set (seconds-oriented).
|
inlineconstexpr |
Default quantiles applied when a summary spec leaves quantiles empty.