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

MetricCore (the shared per-series state) and the CRTP MetricBase that gives every metric type value semantics and lazy binding. More...

#include <prom/adapter.hpp>
#include <prom/dimval.hpp>
#include <prom/global.hpp>
#include <prom/labels.hpp>
#include <prom/unit.hpp>
#include <logman/logman.hpp>
#include <atomic>
#include <cstdint>
#include <memory>
#include <mutex>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
Include dependency graph for metric_base.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  prom::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  prom::detail::DecorationState
 A live, thread-safe metric decoration — a name prefix, default constant labels, and default display metadata — with a version that advances on every change. More...
 
struct  prom::MetricCore
 Shared, reference-counted state behind every metric handle. More...
 
struct  prom::MetricCore::Bound
 
class  prom::MetricBase< Derived >
 CRTP base shared by every metric type. More...
 
struct  prom::MetricBase< Derived >::Binding
 A resolved (adapter, handle) snapshot — the result of bind(). More...
 

Namespaces

namespace  prom
 
namespace  prom::detail
 Portable atomic shared_ptr<const T> exposing just load()/store().
 

Functions

comms::DisplayInfo prom::detail::merge_display (const comms::DisplayInfo &base, const comms::DisplayInfo &over)
 Overlay a metric's own display fields onto a set of defaults; each per-metric field that is set wins over the default.
 
bool prom::detail::display_empty (const comms::DisplayInfo &display) noexcept
 Whether a DisplayInfo carries any field at all.
 
std::shared_ptr< DecorationStateprom::detail::global_decoration ()
 The process-wide decoration shared by Registry::global(), every standalone metric, and (as their chain parent) every Scope.
 

Detailed Description

MetricCore (the shared per-series state) and the CRTP MetricBase that gives every metric type value semantics and lazy binding.

A metric handle is a cheap, copyable value type that holds a shared_ptr<MetricCore>. Copies refer to the same series. A metric is created in one of two states:

Every core reads its adapter from an AdapterSource (the cell of its registry, or the global cell). When that source's version() advances — an adapter swap — or, for a scoped metric, when the scope's version() advances, the core re-registers against the new adapter/config on its next use. Labeled children are pinned: they snapshot their binding at creation and never migrate. After binding, the hot path is a single relaxed load plus a virtual call into the adapter.