userver: /data/code/userver/otlp/include/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
35// clang-format on
36class LoggerComponent final : public components::RawComponentBase {
37 public:
38 static constexpr std::string_view kName = "otlp-logger";
39
40 LoggerComponent(const components::ComponentConfig&,
41 const components::ComponentContext&);
42
43 ~LoggerComponent();
44
45 static yaml_config::Schema GetStaticConfigSchema();
46
47 private:
48 std::shared_ptr<Logger> logger_;
49 logging::LoggerRef old_logger_;
50 utils::statistics::Entry statistics_holder_;
51};
52
53} // namespace otlp
54
55USERVER_NAMESPACE_END