#include <userver/utils/statistics/storage.hpp>
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 |
| Entry utils::statistics::Storage::RegisterExtender | ( | std::string | prefix, |
| ExtenderFunc | func ) |
| 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.
| scopes | storage that owns the writer lifetime. In a component constructor pass context.Scopes() or components::GetResourceScopes. |
| common_prefix | prefix for the metric, for example "my.metric_name" |
| func | function that writes metrics to utils::statistics::Writer |
| add_labels | common labels for the metric, for example {"database", "dbname"} |
| 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.
Store the returned Entry as a member and call Unregister explicitly.