prom 0.1.0
Client-independent C++23 Prometheus/OpenMetrics metric abstraction
Loading...
Searching...
No Matches
Public Member Functions | List of all members
prom::NullAdapter Class Referencefinal

A backend that records nothing. More...

#include <null_adapter.hpp>

Inheritance diagram for prom::NullAdapter:
Inheritance graph
[legend]
Collaboration diagram for prom::NullAdapter:
Collaboration graph
[legend]

Public Member Functions

 NullAdapter ()
 
std::string_view backend_name () const noexcept override
 Stable identifier of the backend (e.g. "null", "prometheus-cpp").
 
MetricHandle register_metric (const MetricMeta &meta) noexcept override
 Register a metric family.
 
MetricHandle resolve (const MetricHandle &, const Labels &dynamic) noexcept override
 Resolve the labeled child of family for the given dynamic labels, creating it on first request.
 
void inc (const MetricHandle &, const double amount) noexcept override
 Increase the series behind handle by amount (counter/gauge).
 
void dec (const MetricHandle &, const double amount) noexcept override
 Decrease the series behind handle by amount (gauge).
 
void set (const MetricHandle &, const double value) noexcept override
 Set the series behind handle to value (gauge/untyped).
 
void observe (const MetricHandle &, const double value) noexcept override
 Record an observation against handle (histogram/summary).
 
void set_info (const MetricHandle &, const std::span< const Label > labels) noexcept override
 Replace the label set carried by an info metric.
 
void set_state (const MetricHandle &, std::string_view state, bool active) noexcept override
 Set the boolean value of one member of a state set.
 
void set_unit (const MetricHandle &, const Unit &unit) noexcept override
 Late unit inference hook.
 
- Public Member Functions inherited from prom::Adapter
 Adapter ()=default
 
 Adapter (const Adapter &)=delete
 
Adapteroperator= (const Adapter &)=delete
 
 Adapter (Adapter &&)=delete
 
Adapteroperator= (Adapter &&)=delete
 
virtual ~Adapter ()=default
 

Detailed Description

A backend that records nothing.

Registration and resolution log at debug and hand back a single shared inert MetricState; mutations log at trace. Logging is null-guarded so construction before any logger setup is safe.

Constructor & Destructor Documentation

◆ NullAdapter()

prom::NullAdapter::NullAdapter ( )
inline

Member Function Documentation

◆ backend_name()

std::string_view prom::NullAdapter::backend_name ( ) const
inlineoverridevirtualnoexcept

Stable identifier of the backend (e.g. "null", "prometheus-cpp").

Implements prom::Adapter.

◆ dec()

void prom::NullAdapter::dec ( const MetricHandle handle,
const double  amount 
)
inlineoverridevirtualnoexcept

Decrease the series behind handle by amount (gauge).

Implements prom::Adapter.

◆ inc()

void prom::NullAdapter::inc ( const MetricHandle handle,
const double  amount 
)
inlineoverridevirtualnoexcept

Increase the series behind handle by amount (counter/gauge).

Implements prom::Adapter.

◆ observe()

void prom::NullAdapter::observe ( const MetricHandle handle,
const double  value 
)
inlineoverridevirtualnoexcept

Record an observation against handle (histogram/summary).

Implements prom::Adapter.

◆ register_metric()

MetricHandle prom::NullAdapter::register_metric ( const MetricMeta meta)
inlineoverridevirtualnoexcept

Register a metric family.

Must return a non-null handle even on failure (fall back to an inert handle) so callers never have to null-check.

Implements prom::Adapter.

◆ resolve()

MetricHandle prom::NullAdapter::resolve ( const MetricHandle family,
const Labels dynamic 
)
inlineoverridevirtualnoexcept

Resolve the labeled child of family for the given dynamic labels, creating it on first request.

The backend owns the child cache. Must return a non-null handle.

Implements prom::Adapter.

◆ set()

void prom::NullAdapter::set ( const MetricHandle handle,
const double  value 
)
inlineoverridevirtualnoexcept

Set the series behind handle to value (gauge/untyped).

Implements prom::Adapter.

◆ set_info()

void prom::NullAdapter::set_info ( const MetricHandle handle,
const std::span< const Label labels 
)
inlineoverridevirtualnoexcept

Replace the label set carried by an info metric.

Implements prom::Adapter.

◆ set_state()

void prom::NullAdapter::set_state ( const MetricHandle handle,
std::string_view  state,
bool  active 
)
inlineoverridevirtualnoexcept

Set the boolean value of one member of a state set.

Implements prom::Adapter.

◆ set_unit()

void prom::NullAdapter::set_unit ( const MetricHandle ,
const Unit  
)
inlineoverridevirtualnoexcept

Late unit inference hook.

Called when a metric that declared no unit latches the unit of its first dimensional observation. Optional — backends that cannot rename a registered series may ignore it.

Reimplemented from prom::Adapter.


The documentation for this class was generated from the following file: