|
prom 0.1.0
Client-independent C++23 Prometheus/OpenMetrics metric abstraction
|
Creates registered metrics against a single adapter cell. More...
#include <registry.hpp>
Public Member Functions | |
| Registry (const Registry &)=delete | |
| Registry & | operator= (const Registry &)=delete |
| Registry (Registry &&)=delete | |
| Registry & | operator= (Registry &&)=delete |
| ~Registry ()=default | |
| AdapterPtr | adapter () const |
| The adapter this registry binds metrics to. | |
| void | set_adapter (AdapterPtr adapter) const |
Install adapter (or reset to a fresh NullAdapter when null) as this registry's backend. | |
| std::string | prefix () const |
| void | set_prefix (std::string prefix) |
| Labels | const_labels () const |
| void | set_const_labels (Labels labels) |
| void | add_const_label (std::string name, std::string value) |
| comms::DisplayInfo | display () const |
| void | set_display (comms::DisplayInfo display) |
| RegistryConfig | config () const |
| A snapshot of the whole decoration. | |
| void | configure (RegistryConfig config) |
| Replace the whole decoration at once (single reconfiguration). | |
| std::vector< MetricInfo > | metrics () const |
| Snapshots describing every (still-alive) metric created from this registry, including declared-but-unused ones. | |
| 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 |
Static Public Member Functions | |
| static std::shared_ptr< Registry > | create (AdapterPtr adapter=nullptr) |
Create a registry with its own cell holding adapter (a fresh NullAdapter when null). | |
| static std::shared_ptr< Registry > | create (AdapterPtr adapter, RegistryConfig config) |
Create a decorating registry: every metric built from it gets config's prefix, default constant labels, and default display, all live- reconfigurable through the registry's setters (mutating them re-registers existing metrics on next use, just like a Scope). | |
| static std::shared_ptr< Registry > | global () |
| The process-wide registry, sharing the global adapter cell and the global decoration. | |
| static std::shared_ptr< Scope > | scope (std::string_view name) |
Get-or-create the process-wide, named Scope (a per-library metrics instance with a shared prefix / default labels / display). | |
| static std::shared_ptr< Scope > | scope (std::string_view name, ScopeConfig config) |
Creates registered metrics against a single adapter cell.
The adapter lives on the registry's AdapterCell. set_adapter swaps it and every metric created from the registry re-registers against the new backend on its next use (the previous backend's series are left behind). The process-wide Registry::global() shares the global cell — the same one standalone and scoped metrics read — so installing a backend with Registry::global()->set_adapter(...) reconfigures everything at once.
Non-copyable and shared_ptr-managed: use Registry::create(...) / Registry::global() and call through ->.
|
delete |
|
delete |
|
default |
|
inline |
The adapter this registry binds metrics to.
|
inline |
|
inline |
A snapshot of the whole decoration.
|
inline |
Replace the whole decoration at once (single reconfiguration).
|
inline |
|
inline |
|
inlinestatic |
Create a decorating registry: every metric built from it gets config's prefix, default constant labels, and default display, all live- reconfigurable through the registry's setters (mutating them re-registers existing metrics on next use, just like a Scope).
|
inlinestatic |
Create a registry with its own cell holding adapter (a fresh NullAdapter when null).
|
inline |
|
inlinestatic |
The process-wide registry, sharing the global adapter cell and the global decoration.
Lets callers create metrics without threading a Registry through their code — see the free prom::counter(...) helpers, which delegate here. Install a backend with prom::Registry::global()->set_adapter(...); install a process-wide prefix / labels with prom::Registry::global()->set_prefix(...) (which reaches standalone and scoped metrics too).
|
inline |
|
inline |
Snapshots describing every (still-alive) metric created from this registry, including declared-but-unused ones.
Expired entries are pruned.
|
inline |
|
inlinestatic |
Get-or-create the process-wide, named Scope (a per-library metrics instance with a shared prefix / default labels / display).
Defined in <prom/scope.hpp> — include it to use these. The two-argument form's config applies only when the scope is first created.
|
inlinestatic |
|
inline |
Install adapter (or reset to a fresh NullAdapter when null) as this registry's backend.
Metrics already created from the registry migrate to it on their next use; series already written to the previous backend stay there (backends cannot move a registered series).
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |