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::logs::Component
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// clang-format off
21
22/// @ingroup userver_components
23///
24/// @brief Component to configure logging via OTLP collector.
25///
26/// ## Static options:
27/// Name | Description | Default value
28/// ---- | ----------- | -------------
29/// endpoint | URI of otel collector (e.g. 127.0.0.1:4317) | -
30/// max-queue-size | Maximum async queue size | 65535
31/// max-batch-delay | Maximum batch delay | 100ms
32/// service-name | Service name | unknown_service
33/// attributes | Extra attributes for OTLP, object of key/value strings | -
34/// sinks | List of sinks | -
35/// sinks.logs | sink for logs (default|otlp|both) | otlp
36/// sinks.tracing | sink for tracing (default|otlp|both) | otlp
37///
38/// Possible sink values:
39/// * `otlp`: OTLP exporter
40/// * `default`: _default_ logger from the `logging` component
41/// * `both`: _default_ logger and OTLP exporter
42
43// clang-format on
44class LoggerComponent final : public components::RawComponentBase {
45public:
46 static constexpr std::string_view kName = "otlp-logger";
47
48 LoggerComponent(const components::ComponentConfig&, const components::ComponentContext&);
49
50 ~LoggerComponent();
51
52 static yaml_config::Schema GetStaticConfigSchema();
53
54private:
55 std::shared_ptr<Logger> logger_;
56 logging::LoggerRef old_logger_;
57 utils::statistics::Entry statistics_holder_;
58};
59
60} // namespace otlp
61
62USERVER_NAMESPACE_END