userver: userver/utils/statistics/system_statistics_collector.hpp Source File
Loading...
Searching...
No Matches
system_statistics_collector.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/utils/statistics/system_statistics_collector.hpp
4/// @brief @copybrief components::SystemStatisticsCollector
5
6#include <memory>
7
8#include <userver/components/component_base.hpp>
9#include <userver/components/component_fwd.hpp>
10
11USERVER_NAMESPACE_BEGIN
12
13namespace utils::statistics {
14
15class Writer;
16
17} // namespace utils::statistics
18
19namespace components {
20
21/// @ingroup userver_components
22///
23/// @brief Component for system resource usage statistics collection.
24///
25/// Periodically queries resource usage info and reports is as a set of metrics.
26///
27/// ## Static options of components::SystemStatisticsCollector :
28/// @include{doc} scripts/docs/en/components_schema/core/src/utils/statistics/system_statistics_collector.md
29///
30/// Options inherited from @ref components::ComponentBase :
31/// @include{doc} scripts/docs/en/components_schema/core/src/components/impl/component_base.md
32///
33/// ## Static configuration example:
34///
35/// @snippet components/common_component_list_test.cpp Sample system statistics component config
36class SystemStatisticsCollector final : public ComponentBase {
37public:
38 /// @ingroup userver_component_names
39 /// @brief The default name of @ref components::SystemStatisticsCollector
40 static constexpr std::string_view kName = "system-statistics-collector";
41
42 SystemStatisticsCollector(const ComponentConfig&, const ComponentContext&);
43 ~SystemStatisticsCollector() override;
44
45 static yaml_config::Schema GetStaticConfigSchema();
46
47private:
48 void ExtendStatistics(utils::statistics::Writer& writer);
49
50 struct Impl;
51 std::unique_ptr<Impl> impl_;
52};
53
54template <>
55inline constexpr bool kHasValidate<SystemStatisticsCollector> = true;
56
57} // namespace components
58
59USERVER_NAMESPACE_END