userver: utils::statistics::Snapshot Class Reference
Loading...
Searching...
No Matches
utils::statistics::Snapshot Class Referencefinal

A snapshot of metrics from utils::statistics::Storage. More...

#include <userver/utils/statistics/testing.hpp>

Public Member Functions

 Snapshot (const Storage &storage, std::string prefix={}, std::vector< Label > require_labels={})
 Create a new snapshot of metrics with paths starting with prefix and labels containing require_labels.
 
 Snapshot (const Snapshot &other)=default
 
 Snapshot (Snapshot &&other) noexcept=default
 
MetricValue SingleMetric (std::string path, std::vector< Label > require_labels={}) const
 Find a single metric by the given filter.
 

Friends

void PrintTo (const Snapshot &data, std::ostream *)
 
std::ostream & operator<< (std::ostream &, const Snapshot &data)
 

Detailed Description

A snapshot of metrics from utils::statistics::Storage.

Definition at line 31 of file testing.hpp.

Constructor & Destructor Documentation

◆ Snapshot()

utils::statistics::Snapshot::Snapshot ( const Storage storage,
std::string  prefix = {},
std::vector< Label require_labels = {} 
)
explicit

Create a new snapshot of metrics with paths starting with prefix and labels containing require_labels.

Exceptions
std::exceptionif a metric writer throws.

Member Function Documentation

◆ SingleMetric()

MetricValue utils::statistics::Snapshot::SingleMetric ( std::string  path,
std::vector< Label require_labels = {} 
) const

Find a single metric by the given filter.

Parameters
pathThe path of the target metric. prefix specified in the constructor is prepended to the path.
require_labelsLabels that the target metric should have.
Returns
The value of the single found metric.
Exceptions
MetricQueryErrorif none or multiple metrics are found.

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