userver: userver/tracing/manager.hpp Source File
Loading...
Searching...
No Matches
manager.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/tracing/manager.hpp
4/// @brief @copybrief tracing::TracingManagerBase
5
6#include <userver/clients/http/request_tracing_editor.hpp>
7#include <userver/clients/http/response.hpp>
8#include <userver/tracing/span.hpp>
9#include <userver/tracing/span_builder.hpp>
10
11USERVER_NAMESPACE_BEGIN
12
13namespace server::http {
14class HttpRequest;
15class HttpResponse;
16} // namespace server::http
17
18namespace tracing {
19
20/// @ingroup userver_base_classes
21///
22/// @brief Base class for propagating trace context information in headers.
23///
24/// Mostly used by tracing::DefaultTracingManagerLocator.
26 public:
27 virtual ~TracingManagerBase() = default;
28
29 /// Fill SpanBuilder params with actual tracing information extracted from the
30 /// request. You should build Span with SpanBuilder::Build, after calling
31 /// this.
32 /// @return Returns bool, that tells us was any of tracing headers used to
33 /// create new span
35 const server::http::HttpRequest& request,
36 SpanBuilder& span_builder) const = 0;
37
38 /// Fill request with tracing information
40 const Span& span, clients::http::RequestTracingEditor request) const = 0;
41
42 /// Fill response with tracing information
44 const Span& span, server::http::HttpResponse& response) const = 0;
45};
46
47/// @brief Used as default tracing manager.
48/// Provides methods for working with usual Yandex.Taxi tracing headers.
49class DefaultTracingManager final : public TracingManagerBase {
50 public:
51 bool TryFillSpanBuilderFromRequest(const server::http::HttpRequest& request,
52 SpanBuilder& span_builder) const override;
53
55 const tracing::Span& span,
56 clients::http::RequestTracingEditor request) const override;
57
59 const Span& span, server::http::HttpResponse& response) const override;
60};
61
62extern const DefaultTracingManager kDefaultTracingManager;
63
64} // namespace tracing
65
66USERVER_NAMESPACE_END