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// 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). This endpoint is used both for logs and traces. If you want separate endpoints, then use below options. | -
30/// logs-endpoint | URI of otel collector (gRPC). This endpoint is used only for logs. | -
31/// tracing-endpoint | URI of otel collector (gRPC). This endpoint is used only for traces. | -
32/// client-factory-name | Name of the grpc client factory | -
33/// max-queue-size | Maximum async queue size | 65535
34/// max-batch-delay | Maximum batch delay | 100ms
35/// service-name | Service name | unknown_service
36/// attributes | Extra attributes for OTLP, object of key/value strings | -
37/// sinks | List of sinks | -
38/// sinks.logs | sink for logs (default|otlp|both) | otlp
39/// sinks.tracing | sink for tracing (default|otlp|both) | otlp
40///
41/// Possible sink values:
42/// * `otlp`: OTLP exporter
43/// * `default`: _default_ logger from the `logging` component
44/// * `both`: _default_ logger and OTLP exporter
45
46// clang-format on
47class LoggerComponent final : public components::RawComponentBase {
48public:
49 /// @ingroup userver_component_names
50 /// @brief The default name of otlp::LoggerComponent
51 static constexpr std::string_view kName = "otlp-logger";
52
53 LoggerComponent(const components::ComponentConfig&, const components::ComponentContext&);
54
55 ~LoggerComponent();
56
57 static yaml_config::Schema GetStaticConfigSchema();
58
59private:
60 std::shared_ptr<Logger> logger_;
61 logging::LoggerRef old_logger_;
62 utils::statistics::Entry statistics_holder_;
63};
64
65} // namespace otlp
66
67USERVER_NAMESPACE_END