userver: userver/tracing/span_builder.hpp Source File
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
span_builder.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/tracing/span_builder.hpp
4/// @brief @copybrief tracing::SpanBuilder
5
6#include <string>
7#include <string_view>
8
9#include <userver/tracing/span.hpp>
10#include <userver/utils/impl/source_location.hpp>
11
12USERVER_NAMESPACE_BEGIN
13
14namespace tracing {
15
16/// @brief Provides interface for editing Span, before final building.
17class SpanBuilder final {
18public:
19 explicit SpanBuilder(
20 std::string name,
21 const utils::impl::SourceLocation& location = utils::impl::SourceLocation::Current()
22 );
23
24 void SetTraceId(std::string_view trace_id);
25 std::string_view GetTraceId() const noexcept;
26 void SetSpanId(std::string_view span_id);
27 void SetLink(std::string_view link);
28 void SetParentSpanId(std::string_view parent_span_id);
29 void SetParentLink(std::string_view parent_link);
30
31 void AddTagFrozen(std::string key, logging::LogExtra::Value value);
32 void AddNonInheritableTag(std::string key, logging::LogExtra::Value value);
33
34 Span Build() &&;
35 Span BuildDetachedFromCoroStack() &&;
36
37private:
38 std::unique_ptr<Span::Impl, Span::OptionalDeleter> pimpl_;
39};
40
41} // namespace tracing
42
43USERVER_NAMESPACE_END