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

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

Detailed Description

Storage of metrics, usually retrieved from components::StatisticsStorage.

See utils::statistics::Writer for an information on how to write metrics.

For introduction to metrics see Statistics and Metrics

Definition at line 35 of file storage.hpp.

Public Member Functions

 Storage (const Storage &)=delete
Storage & operator= (const Storage &)=delete
void RegisterWriter (ResourceScopeStorage &scopes, std::string common_prefix, WriterFunc func, std::vector< Label > add_labels={})
 Add a writer function func. Note that func is called concurrently with other code, so it should be thread-safe.

Member Function Documentation

◆ RegisterWriter()

void utils::statistics::Storage::RegisterWriter ( ResourceScopeStorage & scopes,
std::string common_prefix,
WriterFunc func,
std::vector< Label > add_labels = {} )

Add a writer function func. Note that func is called concurrently with other code, so it should be thread-safe.

Registration runs after construction via ResourceScopeStorage::AfterConstruction. Unregister runs in ResourceScopeStorage::BeforeDestruction. The storage must outlive its registrations. If other scopes initialize or destroy data accessed by func (generally discouraged), register the statistics scope after them so the data is initialized before the callback is registered and destroyed after it is unregistered.

In a component constructor prefer RegisterWriterScope with components::ComponentContext.

Parameters
scopesstorage that owns the writer lifetime. See where to obtain scopes.
common_prefixprefix for the metric, for example "my.metric_name"
funcfunction that writes metrics to utils::statistics::Writer
add_labelscommon labels for the metric, for example {"database", "dbname"}

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