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

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...

#include <metric_base.hpp>

Inheritance diagram for prom::detail::DecorationState:
Inheritance graph
[legend]
Collaboration diagram for prom::detail::DecorationState:
Collaboration graph
[legend]

Public Member Functions

 DecorationState ()=default
 
 DecorationState (std::string prefix, Labels const_labels, comms::DisplayInfo display, std::shared_ptr< ScopeState > parent=nullptr)
 
std::uint64_t version () const noexcept override
 Monotonic counter, bumped on every configuration change.
 
std::string full_name (const std::string_view base) const override
 The effective metric name for a base (un-prefixed) name.
 
Labels effective_labels (const Labels &own) const override
 The effective constant labels for a metric's own labels.
 
comms::DisplayInfo effective_display (const comms::DisplayInfo &own) const override
 The effective display metadata for a metric's own display.
 
bool decorates () const noexcept override
 Whether this decoration actually changes anything (a non-empty prefix, constant labels, or display — directly or via a parent it chains onto).
 
std::string prefix () const
 
void set_prefix (std::string prefix)
 
Labels const_labels () const
 
void set_const_labels (Labels labels)
 
void add_const_label (std::string name, std::string value)
 
comms::DisplayInfo display () const
 
void set_display (comms::DisplayInfo display)
 
void configure (std::string prefix, Labels const_labels, comms::DisplayInfo display)
 Replace prefix, constant labels, and display in one shot (single version bump).
 
- Public Member Functions inherited from prom::ScopeState
 ScopeState ()=default
 
 ScopeState (const ScopeState &)=delete
 
ScopeStateoperator= (const ScopeState &)=delete
 
 ScopeState (ScopeState &&)=delete
 
ScopeStateoperator= (ScopeState &&)=delete
 
virtual ~ScopeState ()=default
 

Detailed Description

A live, thread-safe metric decoration — a name prefix, default constant labels, and default display metadata — with a version that advances on every change.

This is the engine behind both a prom::Scope and a prom::Registry: a metric core that points at one (via MetricCore::scope) re-resolves its effective name / labels / display whenever version() moves (see MetricBase::rebind), so mutating the decoration at runtime reconfigures every metric created against it.

A decoration may chain onto a parent (a scope chains onto the global registry's decoration), in which case the parent is applied outermost: parent.prefix + this.prefix + base. The metric's own values still win over this, which wins over the parent. The version composes both, so a change to either re-registers the metric.

Constructor & Destructor Documentation

◆ DecorationState() [1/2]

prom::detail::DecorationState::DecorationState ( )
default

◆ DecorationState() [2/2]

prom::detail::DecorationState::DecorationState ( std::string  prefix,
Labels  const_labels,
comms::DisplayInfo  display,
std::shared_ptr< ScopeState parent = nullptr 
)
inline

Member Function Documentation

◆ add_const_label()

void prom::detail::DecorationState::add_const_label ( std::string  name,
std::string  value 
)
inline

◆ configure()

void prom::detail::DecorationState::configure ( std::string  prefix,
Labels  const_labels,
comms::DisplayInfo  display 
)
inline

Replace prefix, constant labels, and display in one shot (single version bump).

◆ const_labels()

Labels prom::detail::DecorationState::const_labels ( ) const
inline

◆ decorates()

bool prom::detail::DecorationState::decorates ( ) const
inlineoverridevirtualnoexcept

Whether this decoration actually changes anything (a non-empty prefix, constant labels, or display — directly or via a parent it chains onto).

Drives the scoped flag on MetricInfo: an empty decoration leaves a metric reported as un-decorated.

Implements prom::ScopeState.

◆ display()

comms::DisplayInfo prom::detail::DecorationState::display ( ) const
inline

◆ effective_display()

comms::DisplayInfo prom::detail::DecorationState::effective_display ( const comms::DisplayInfo &  own) const
inlineoverridevirtual

The effective display metadata for a metric's own display.

Implements prom::ScopeState.

◆ effective_labels()

Labels prom::detail::DecorationState::effective_labels ( const Labels own) const
inlineoverridevirtual

The effective constant labels for a metric's own labels.

Implements prom::ScopeState.

◆ full_name()

std::string prom::detail::DecorationState::full_name ( const std::string_view  base) const
inlineoverridevirtual

The effective metric name for a base (un-prefixed) name.

Implements prom::ScopeState.

◆ prefix()

std::string prom::detail::DecorationState::prefix ( ) const
inline

◆ set_const_labels()

void prom::detail::DecorationState::set_const_labels ( Labels  labels)
inline

◆ set_display()

void prom::detail::DecorationState::set_display ( comms::DisplayInfo  display)
inline

◆ set_prefix()

void prom::detail::DecorationState::set_prefix ( std::string  prefix)
inline

◆ version()

std::uint64_t prom::detail::DecorationState::version ( ) const
inlineoverridevirtualnoexcept

Monotonic counter, bumped on every configuration change.

Implements prom::ScopeState.


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