|
prom 0.1.0
Client-independent C++23 Prometheus/OpenMetrics metric abstraction
|
CompositeAdapter — fan one metric out to several backends at once.
More...
#include <prom/adapter.hpp>#include <prom/fwd.hpp>#include <prom/labels.hpp>#include <prom/unit.hpp>#include <logman/logman.hpp>#include <algorithm>#include <cstddef>#include <initializer_list>#include <memory>#include <span>#include <string_view>#include <utility>#include <vector>

Go to the source code of this file.
Classes | |
| class | prom::CompositeState |
| Backend state for a composite family or child: the index-aligned bundle of the handles each wrapped adapter returned. More... | |
| class | prom::CompositeAdapter |
| A backend that forwards every call to a fixed set of child adapters. More... | |
Namespaces | |
| namespace | prom |
CompositeAdapter — fan one metric out to several backends at once.
A CompositeAdapter holds a fixed list of child adapters and forwards every Adapter call to each of them. Install it like any other backend (set_adapter(std::make_shared<CompositeAdapter>(...))) to, for example, feed both a real prometheus-cpp backend and a test-recording backend from a single set of metrics, or to tee metrics to two exporters during a migration.
The wrinkle is that register_metric/resolve each return one MetricHandle, but every child hands back its own. The composite solves this by bundling the per-child handles into a CompositeState: the handle prom holds is a CompositeState whose handles[i] is the handle child i returned. Each mutation then dispatches handles[i] to child i.