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

The process-wide adapter cell and its install/swap semantics. More...

#include <prom/adapter.hpp>
#include <prom/null_adapter.hpp>
#include <atomic>
#include <cstdint>
#include <memory>
#include <mutex>
#include <utility>
Include dependency graph for global.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  prom::AdapterCell
 A swappable adapter slot shared by every metric that reads from it. More...
 

Namespaces

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

Detailed Description

The process-wide adapter cell and its install/swap semantics.

The adapter no longer lives on each metric — it lives on an AdapterCell (an AdapterSource) that metrics read through. Standalone and scoped metrics share the process-wide cell returned by detail::global_adapter_cell(); a Registry owns its own cell. Install the real backend on a cell and every metric reading from it migrates to the new backend on its next use:

prom::Registry::global()->set_adapter(std::make_shared<my::Backend>(...));
static std::shared_ptr< Registry > global()
The process-wide registry, sharing the global adapter cell and the global decoration.
Definition registry.hpp:147

The default adapter is a NullAdapter, so metrics are always safe to use before any backend is installed.