#include <userver/utils/statistics/writer.hpp>
Class for writing metrics.
The Writer could be customized by providing a void DumpMetric(utils::statistics::Writer& writer, const Metric& value)
function:
DumpMetric functions nest well, labels are propagated to the nested DumpMetric:
To use the above writers register the metric writer in utils::statistics::Storage component:
The above metrics in Graphite format would look like:
The Writer is usable by the utils::statistics::MetricTag. For example, for the following structure:
The DumpMetric function may look like:
For information on metrics testing in testsuite refer to Testsuite - Metrics.
For metrics testing in unit-tests see utils::statistics::Snapshot.
Definition at line 85 of file writer.hpp.
Public Member Functions | |
Writer (Writer &&other)=delete | |
Writer (const Writer &)=delete | |
Writer & | operator= (Writer &&)=delete |
Writer & | operator= (const Writer &)=delete |
Writer | operator[] (std::string_view path) & |
Returns a Writer with a ('.' + path) appended. | |
Writer | operator[] (std::string_view path) && |
Returns a Writer with a ('.' + path) appended. | |
template<class T > | |
void | operator= (const T &value) |
template<class T > | |
void | ValueWithLabels (const T &value, LabelsSpan labels) |
Write metric value with labels to metrics builder. | |
template<class T > | |
void | ValueWithLabels (const T &value, std::initializer_list< LabelView > il) |
Write metric value with labels to metrics builder. | |
template<class T > | |
void | ValueWithLabels (const T &value, const LabelView &label) |
Write metric value with label to metrics builder. | |
operator bool () const noexcept | |
Static Public Attributes | |
static constexpr char | kDelimiter = '.' |
Path parts delimiter. In other words, writer["a"]["b"] becomes "a.b". | |
|
inlineexplicitnoexcept |
Returns true if this writer would actually write data. Returns false if the data is not required by request and metrics construction could be skipped.
Definition at line 147 of file writer.hpp.
Write metric value to metrics builder via using DumpMetric function.
Definition at line 107 of file writer.hpp.
|
inline |
Write metric value with label to metrics builder.
Definition at line 140 of file writer.hpp.
|
inline |
Write metric value with labels to metrics builder.
Definition at line 126 of file writer.hpp.
|
inline |
Write metric value with labels to metrics builder.
Definition at line 134 of file writer.hpp.
Path parts delimiter. In other words, writer["a"]["b"] becomes "a.b".
Definition at line 88 of file writer.hpp.