userver: userver/tracing/span_builder.hpp Source File
Loading...
Searching...
No Matches
span_builder.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <string>
7#include <string_view>
8
10#include <userver/utils/impl/source_location.hpp>
11
12USERVER_NAMESPACE_BEGIN
13
14namespace tracing {
15
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 void SetLocalLogLevel(logging::Level log_level) noexcept;
35
37 void SetSampled(bool sampled) noexcept;
38
39 Span Build() &&;
40 Span BuildDetachedFromCoroStack() &&;
41
42private:
43 std::unique_ptr<Span::Impl, Span::OptionalDeleter> pimpl_;
44};
45
46} // namespace tracing
47
48USERVER_NAMESPACE_END