userver: userver/otlp/logs/component.hpp Source File
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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// 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/// client-factory-name | Name of the grpc client factory | -
31/// max-queue-size | Maximum async queue size | 65535
32/// max-batch-delay | Maximum batch delay | 100ms
33/// service-name | Service name | unknown_service
34/// attributes | Extra attributes for OTLP, object of key/value strings | -
35/// sinks | List of sinks | -
36/// sinks.logs | sink for logs (default|otlp|both) | otlp
37/// sinks.tracing | sink for tracing (default|otlp|both) | otlp
38///
39/// Possible sink values:
40/// * `otlp`: OTLP exporter
41/// * `default`: _default_ logger from the `logging` component
42/// * `both`: _default_ logger and OTLP exporter
43
44// clang-format on
45class LoggerComponent final : public components::RawComponentBase {
46public:
47 static constexpr std::string_view kName = "otlp-logger";
48
49 LoggerComponent(const components::ComponentConfig&, const components::ComponentContext&);
50
51 ~LoggerComponent();
52
53 static yaml_config::Schema GetStaticConfigSchema();
54
55private:
56 std::shared_ptr<Logger> logger_;
57 logging::LoggerRef old_logger_;
58 utils::statistics::Entry statistics_holder_;
59};
60
61} // namespace otlp
62
63USERVER_NAMESPACE_END