6#include <userver/components/component_fwd.hpp>
7#include <userver/components/raw_component_base.hpp>
8#include <userver/utils/statistics/metrics_storage.hpp>
9#include <userver/utils/statistics/storage.hpp>
11USERVER_NAMESPACE_BEGIN
27class StatisticsStorage
final :
public RawComponentBase {
31 static constexpr std::string_view
kName =
"statistics-storage";
33 StatisticsStorage(
const ComponentConfig& config,
const ComponentContext& context);
35 ~StatisticsStorage()
override;
37 void OnAllComponentsLoaded()
override;
39 utils::statistics::Storage& GetStorage() {
return storage_; }
41 const utils::statistics::Storage& GetStorage()
const {
return storage_; }
43 utils::statistics::MetricsStoragePtr GetMetricsStorage() {
return metrics_storage_; }
45 utils::statistics::MetricsStorage& GetMetricsStorageRef() {
46 UASSERT(metrics_storage_ !=
nullptr);
47 return *metrics_storage_;
50 static yaml_config::Schema GetStaticConfigSchema();
53 utils::statistics::Storage storage_;
54 utils::statistics::MetricsStoragePtr metrics_storage_;
55 std::vector<utils::statistics::Entry> metrics_storage_registration_;
59inline constexpr bool kHasValidate<StatisticsStorage> =
true;
62inline constexpr auto kConfigFileMode<StatisticsStorage> = ConfigFileMode::kNotRequired;
66namespace utils::statistics {
74void RegisterWriterScope(
75 const components::ComponentContext&,
76 std::string common_prefix,
78 std::vector<Label> add_labels = {}