userver: userver/tracing/manager_component.hpp Source File
Loading...
Searching...
No Matches
manager_component.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/tracing/manager_component.hpp
4/// @brief TracingManager base and default components
5
6#include <string>
7
8#include <userver/components/loggable_component_base.hpp>
9#include <userver/tracing/manager.hpp>
10#include <userver/tracing/span.hpp>
11
12USERVER_NAMESPACE_BEGIN
13
14namespace tracing {
15
16/// @brief Base component for implementing TracingManager component
17// NOLINTNEXTLINE(fuchsia-multiple-inheritance)
19 public TracingManagerBase {
20 public:
21 TracingManagerComponentBase(const components::ComponentConfig&,
22 const components::ComponentContext&);
23};
24
25// clang-format off
26
27/// @ingroup userver_components
28///
29/// @brief Component that provides access to the actual TracingManager
30/// that is used in handlers and clients.
31///
32/// This component allows conversion of tracing formats and allows working with
33/// multiple tracing formats. For example:
34/// @code
35/// # yaml
36/// incoming-format: ['opentelemetry', 'taxi']
37/// new-requests-format: ['b3-alternative', 'opentelemetry']
38/// @endcode
39/// means that tracing data is extracted from OpenTelemetry headers if they
40/// were received or from Yandex-Taxi specific headers. The outgoing requests
41/// will have the tracing::Format::kB3Alternative headers and OpenTelemetry
42/// headers at the same time.
43///
44/// The component can be configured in service config.
45///
46/// ## Static options:
47/// Name | Description | Default value
48/// ---- | ----------- | -------------
49/// component-name | name of the component, that implements TracingManagerComponentBase | <use tracing::GenericTracingManager with below settings>
50/// incoming-format | Array of incoming tracing formats supported by tracing::FormatFromString | ['taxi']
51/// new-requests-format | Send tracing data in those formats supported by tracing::FormatFromString | ['taxi']
52///
53// clang-format on
54class DefaultTracingManagerLocator final
56 public:
57 /// @ingroup userver_component_names
58 /// @brief The default name of tracing::DefaultTracingManagerLocator
59 static constexpr std::string_view kName = "tracing-manager-locator";
60
61 DefaultTracingManagerLocator(const components::ComponentConfig&,
62 const components::ComponentContext&);
63
64 const TracingManagerBase& GetTracingManager() const;
65
66 static yaml_config::Schema GetStaticConfigSchema();
67
68 private:
69 GenericTracingManager default_manager_;
70 const TracingManagerBase& tracing_manager_;
71};
72
73} // namespace tracing
74
75template <>
76inline constexpr bool
77 components::kHasValidate<tracing::DefaultTracingManagerLocator> = true;
78
79template <>
80inline constexpr auto
81 components::kConfigFileMode<tracing::DefaultTracingManagerLocator> =
83
84USERVER_NAMESPACE_END