#include <userver/utils/statistics/testing.hpp>
A snapshot of metrics dumped via Writer.
Definition at line 32 of file testing.hpp.
Public Member Functions | |
| Snapshot (const HasWriterSupport auto &metric, std::string prefix={}, std::vector< Label > require_labels={}) | |
| Create a snapshot by dumping metric via Writer. | |
| Snapshot (WriterFuncRef writer, std::string prefix={}, std::vector< Label > require_labels={}) | |
| Create a snapshot by invoking writer. | |
| 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. | |
|
inlineexplicit |
Create a snapshot by dumping metric via Writer.
metric is any type with Writer support. For simple metrics prefer a type with DumpMetric and pass it directly:
utils::statistics::Storage also works — passing Storage is still a common usage when writers are registered there:
Keeps metrics whose path starts with prefix and labels containing require_labels.
| std::exception | if the Writer dump throws. |
Definition at line 47 of file testing.hpp.
|
explicit |
Create a snapshot by invoking writer.
prefix and require_labels select metrics the same way as for the metric constructor. The callback writes paths relative to an internal test prefix; prefix is not prepended to what the callback writes.
| MetricValue utils::statistics::Snapshot::SingleMetric | ( | std::string | path, |
| std::vector< Label > | require_labels = {} ) const |
Find a single metric by the given filter.
| 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. |
| MetricQueryError | if none or multiple metrics are found. |
|
friend |
Support for gtest diagnostics for utils::statistics::Snapshot.
Valid usage:
Invalid usage: