#include <userver/utils/statistics/testing.hpp>
A snapshot of metrics from utils::statistics::Storage.
Definition at line 32 of file testing.hpp.
|
| 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.
|
|
std::optional< MetricValue > | SingleMetricOptional (std::string path, std::vector< Label > require_labels={}) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
|
◆ 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::exception | if a metric writer throws. |
◆ SingleMetric()
MetricValue utils::statistics::Snapshot::SingleMetric |
( |
std::string | path, |
|
|
std::vector< Label > | require_labels = {} ) const |
Find a single metric by the given filter.
- Parameters
-
path | The path of the target metric. prefix specified in the constructor is prepended to the path. |
require_labels | Labels that the target metric should have. |
- Returns
- The value of the single found metric.
- Exceptions
-
◆ PrintTo
void PrintTo |
( |
const Snapshot & | data, |
|
|
std::ostream * | ) |
|
friend |
Support for gtest diagnostics for utils::statistics::Snapshot.
- Warning
- Never check the printed value programmatically! The string is not stable and may change, depending on the version of stdlib and userver.
Valid usage:
EXPECT_EQ(..., ...) << testing::PrintToString(snapshot);
Invalid usage:
std::ostringstream stream;
EXPECT_EQ(stream.str(), ...);
The documentation for this class was generated from the following file: