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 56 of file storage.hpp.

Public Member Functions

 Storage (const Storage &)=delete
void VisitMetrics (BaseFormatBuilder &out, const Request &request={}) const
 Visits all the metrics and calls out.HandleMetric for each metric.
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.
Entry RegisterWriter (std::string common_prefix, WriterFunc func, std::vector< Label > add_labels={})
Entry RegisterExtender (std::string prefix, ExtenderFunc func)
void UnregisterExtender (impl::StorageIterator iterator, impl::UnregisteringKind kind) noexcept

Member Function Documentation

◆ RegisterExtender()

Entry utils::statistics::Storage::RegisterExtender ( std::string prefix,
ExtenderFunc func )
Deprecated
Use RegisterWriter instead.

◆ RegisterWriter() [1/2]

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.

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

Parameters
scopesstorage that owns the writer lifetime. In a component constructor pass context.Scopes() or components::GetResourceScopes.
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"}

◆ RegisterWriter() [2/2]

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Deprecated
Use the overload that takes utils::ResourceScopeStorage.

Store the returned Entry as a member and call Unregister explicitly.


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