prom 0.1.0
Client-independent C++23 Prometheus/OpenMetrics metric abstraction
Loading...
Searching...
No Matches
Classes | Namespaces | Functions
registry.hpp File Reference

Registry — the front door for creating registered metrics. More...

#include <prom/adapter.hpp>
#include <prom/counter.hpp>
#include <prom/error.hpp>
#include <prom/gauge.hpp>
#include <prom/global.hpp>
#include <prom/histogram.hpp>
#include <prom/info.hpp>
#include <prom/labels.hpp>
#include <prom/metric_base.hpp>
#include <prom/stateset.hpp>
#include <prom/summary.hpp>
#include <prom/unit.hpp>
#include <prom/untyped.hpp>
#include <cmath>
#include <cstddef>
#include <memory>
#include <mutex>
#include <optional>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
Include dependency graph for registry.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  prom::RegistryConfig
 The decoration a Registry applies to every metric created through it: a name prefix, default constant labels, and default display metadata. More...
 
struct  prom::MetricInfo
 A read-only snapshot describing one registered metric, returned by the enumeration APIs (Registry::metrics, Scope::metrics). More...
 
class  prom::Registry
 Creates registered metrics against a single adapter cell. More...
 

Namespaces

namespace  prom
 

Functions

MetricInfo prom::describe (const MetricCore &core)
 Build a MetricInfo from a core, applying scope decoration for a scoped metric's effective name and constant labels.
 
Counter prom::counter (const CounterSpec &spec)
 
Gauge prom::gauge (const GaugeSpec &spec)
 
Histogram prom::histogram (const HistogramSpec &spec)
 
Summary prom::summary (const SummarySpec &spec)
 
Untyped prom::untyped (const UntypedSpec &spec)
 
Info prom::info (const InfoSpec &spec)
 
StateSet prom::stateset (const StateSetSpec &spec)
 
expected< Counterprom::try_counter (const CounterSpec &spec) noexcept
 
expected< Gaugeprom::try_gauge (const GaugeSpec &spec) noexcept
 
expected< Histogramprom::try_histogram (const HistogramSpec &spec) noexcept
 
expected< Summaryprom::try_summary (const SummarySpec &spec) noexcept
 
expected< Untypedprom::try_untyped (const UntypedSpec &spec) noexcept
 
expected< Infoprom::try_info (const InfoSpec &spec) noexcept
 
expected< StateSetprom::try_stateset (const StateSetSpec &spec) noexcept
 

Detailed Description

Registry — the front door for creating registered metrics.

A Registry owns an AdapterCell: the adapter lives on the registry, not on the metrics it creates, so swapping the registry's adapter reconfigures every metric created from it (each re-registers against the new backend on its next use). Each factory validates its spec, builds a stable MetricCore pointing at the registry's cell, eagerly registers the family, tracks it for enumeration, and returns a typed metric. The throwing factories (counter, ...) raise prom::Exception; the try_* mirrors are noexcept and return prom::expected.

Registry is non-copyable and shared_ptr-managed: obtain one with Registry::create(adapter) or the process-wide Registry::global(), and use it through ->.

The *Spec structs live with their metric types (<prom/counter.hpp> …) and are all visible through this header.