userver: userver/tracing/span_builder.hpp Source File
⚠️ This is the documentation for an old userver version. Click here to switch to the latest version.
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
8#include <userver/tracing/span.hpp>
9#include <userver/utils/impl/source_location.hpp>
10
11USERVER_NAMESPACE_BEGIN
12
13namespace tracing {
14
15/// @brief Provides interface for editing Span, before final building.
16class SpanBuilder final {
17 public:
18 explicit SpanBuilder(std::string name,
19 const utils::impl::SourceLocation& location =
20 utils::impl::SourceLocation::Current());
21
22 void SetTraceId(std::string trace_id);
23 const std::string& GetTraceId() const noexcept;
24 void SetSpanId(std::string span_id);
25 void SetParentSpanId(std::string parent_span_id);
26 void SetParentLink(std::string parent_link);
27 void AddTagFrozen(std::string key, logging::LogExtra::Value value);
28 void AddNonInheritableTag(std::string key, logging::LogExtra::Value value);
29 Span Build() &&;
30
31 private:
32 std::unique_ptr<Span::Impl, Span::OptionalDeleter> pimpl_;
33};
34
35} // namespace tracing
36
37USERVER_NAMESPACE_END