userver: userver/otlp/logs/component.hpp Source File
Loading...
Searching...
No Matches
component.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/otlp/logs/component.hpp
4/// @brief @copybrief otlp::LoggerComponent
5
6#include <memory>
7#include <string>
8
9#include <userver/components/component_fwd.hpp>
10#include <userver/components/raw_component_base.hpp>
11#include <userver/logging/fwd.hpp>
12#include <userver/utils/statistics/entry.hpp>
13
14USERVER_NAMESPACE_BEGIN
15
16namespace otlp {
17
18class Logger;
19
20/// @ingroup userver_components
21///
22/// @brief Component to configure logging via OTLP collector.
23///
24/// ## Static options of otlp::LoggerComponent :
25/// @include{doc} scripts/docs/en/components_schema/otlp/src/otlp/logs/component.md
26///
27/// Options inherited from @ref components::ComponentBase :
28/// @include{doc} scripts/docs/en/components_schema/core/src/components/impl/component_base.md
29///
30/// Possible sink values:
31/// * `otlp`: OTLP exporter
32/// * `default`: _default_ logger from the `logging` component
33/// * `both`: _default_ logger and OTLP exporter
34class LoggerComponent final : public components::RawComponentBase {
35public:
36 /// @ingroup userver_component_names
37 /// @brief The default name of otlp::LoggerComponent
38 static constexpr std::string_view kName = "otlp-logger";
39
40 LoggerComponent(const components::ComponentConfig&, const components::ComponentContext&);
41
42 ~LoggerComponent();
43
44 static yaml_config::Schema GetStaticConfigSchema();
45
46private:
47 std::shared_ptr<Logger> logger_;
48 logging::LoggerRef old_logger_;
49 utils::statistics::Entry statistics_holder_;
50};
51
52} // namespace otlp
53
54USERVER_NAMESPACE_END