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/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)
19public:
20 TracingManagerComponentBase(const components::ComponentConfig&, const components::ComponentContext&);
21};
22
23/// @ingroup userver_components
24///
25/// @brief Component that provides access to the actual TracingManager
26/// that is used in handlers and clients.
27///
28/// This component allows conversion of tracing formats and allows working with
29/// multiple tracing formats. For example:
30/// @code
31/// # yaml
32/// incoming-format: ['opentelemetry', 'taxi']
33/// new-requests-format: ['b3-alternative', 'opentelemetry']
34/// @endcode
35/// means that tracing data is extracted from OpenTelemetry headers if they
36/// were received or from Yandex-Taxi specific headers. The outgoing requests
37/// will have the tracing::Format::kB3Alternative headers and OpenTelemetry
38/// headers at the same time.
39///
40/// The component can be configured in service config.
41///
42/// ## Static options of tracing::DefaultTracingManagerLocator :
43/// @include{doc} scripts/docs/en/components_schema/core/src/tracing/manager_component.md
44///
45/// Options inherited from @ref components::ComponentBase :
46/// @include{doc} scripts/docs/en/components_schema/core/src/components/impl/component_base.md
47class DefaultTracingManagerLocator final : public components::ComponentBase {
48public:
49 /// @ingroup userver_component_names
50 /// @brief The default name of @ref tracing::DefaultTracingManagerLocator
51 static constexpr std::string_view kName = "tracing-manager-locator";
52
53 DefaultTracingManagerLocator(const components::ComponentConfig&, const components::ComponentContext&);
54
55 const TracingManagerBase& GetTracingManager() const;
56
57 static yaml_config::Schema GetStaticConfigSchema();
58
59private:
60 GenericTracingManager default_manager_;
61 const TracingManagerBase& tracing_manager_;
62};
63
64} // namespace tracing
65
66template <>
67inline constexpr bool components::kHasValidate<tracing::DefaultTracingManagerLocator> = true;
68
69template <>
70inline constexpr auto components::kConfigFileMode<tracing::DefaultTracingManagerLocator> = ConfigFileMode::kNotRequired;
71
72USERVER_NAMESPACE_END