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

A named, reconfigurable metrics instance for one library. More...

#include <scope.hpp>

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

Public Member Functions

 Scope (ScopeConfig config={})
 
Counter counter (const CounterSpec &spec)
 
Gauge gauge (const GaugeSpec &spec)
 
Histogram histogram (const HistogramSpec &spec)
 
Summary summary (const SummarySpec &spec)
 
Untyped untyped (const UntypedSpec &spec)
 
Info info (const InfoSpec &spec)
 
StateSet stateset (const StateSetSpec &spec)
 
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)
 
ScopeConfig config () const
 A snapshot of the whole configuration.
 
void configure (ScopeConfig config)
 Replace the whole configuration at once.
 
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::vector< MetricInfometrics () const
 Snapshots describing every (still-alive) metric created through this scope, including declared-but-unused ones; the effective name and labels are computed live from the current scope config.
 
- 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 named, reconfigurable metrics instance for one library.

Create/retrieve it with prom::scope(...) (or prom::Registry::scope(...)); it is held by shared_ptr so the metrics created from it keep it alive.

Constructor & Destructor Documentation

◆ Scope()

prom::Scope::Scope ( ScopeConfig  config = {})
inlineexplicit

Member Function Documentation

◆ add_const_label()

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

◆ config()

ScopeConfig prom::Scope::config ( ) const
inline

A snapshot of the whole configuration.

◆ configure()

void prom::Scope::configure ( ScopeConfig  config)
inline

Replace the whole configuration at once.

◆ const_labels()

Labels prom::Scope::const_labels ( ) const
inline

◆ counter()

Counter prom::Scope::counter ( const CounterSpec spec)
inline

◆ decorates()

bool prom::Scope::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::Scope::display ( ) const
inline

◆ effective_display()

comms::DisplayInfo prom::Scope::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::Scope::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::Scope::full_name ( const std::string_view  base) const
inlineoverridevirtual

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

Implements prom::ScopeState.

◆ gauge()

Gauge prom::Scope::gauge ( const GaugeSpec spec)
inline

◆ histogram()

Histogram prom::Scope::histogram ( const HistogramSpec spec)
inline

◆ info()

Info prom::Scope::info ( const InfoSpec spec)
inline

◆ metrics()

std::vector< MetricInfo > prom::Scope::metrics ( ) const
inline

Snapshots describing every (still-alive) metric created through this scope, including declared-but-unused ones; the effective name and labels are computed live from the current scope config.

Expired entries are pruned. Kept separate from Registry::global()->metrics().

◆ prefix()

std::string prom::Scope::prefix ( ) const
inline

◆ set_const_labels()

void prom::Scope::set_const_labels ( Labels  labels)
inline

◆ set_display()

void prom::Scope::set_display ( comms::DisplayInfo  display)
inline

◆ set_prefix()

void prom::Scope::set_prefix ( std::string  prefix)
inline

◆ stateset()

StateSet prom::Scope::stateset ( const StateSetSpec spec)
inline

◆ summary()

Summary prom::Scope::summary ( const SummarySpec spec)
inline

◆ untyped()

Untyped prom::Scope::untyped ( const UntypedSpec spec)
inline

◆ version()

std::uint64_t prom::Scope::version ( ) const
inlineoverridevirtualnoexcept

Monotonic counter, bumped on every configuration change.

Implements prom::ScopeState.


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