9#include <userver/logging/log.hpp>
10#include <userver/logging/log_extra.hpp>
11#include <userver/tracing/scope_time.hpp>
12#include <userver/tracing/tracer_fwd.hpp>
13#include <userver/utils/impl/source_location.hpp>
14#include <userver/utils/internal_tag_fwd.hpp>
16USERVER_NAMESPACE_BEGIN
34 explicit Span(TracerPtr tracer, std::string name,
const Span* parent,
35 ReferenceType reference_type,
37 utils::impl::SourceLocation source_location =
38 utils::impl::SourceLocation::Current());
41
42 explicit Span(std::string name,
43 ReferenceType reference_type = ReferenceType::kChild,
45 utils::impl::SourceLocation source_location =
46 utils::impl::SourceLocation::Current());
50 explicit Span(Span::Impl& impl);
53 Span(Span&& other)
noexcept;
57 Span& operator=(
const Span&) =
delete;
59 Span& operator=(Span&&) =
delete;
77 static Span
MakeSpan(std::string name, std::string_view trace_id,
78 std::string_view parent_span_id);
81 static Span
MakeSpan(std::string name, std::string_view trace_id,
82 std::string_view parent_span_id, std::string link);
90 Span CreateFollower(std::string name)
const;
108 const std::string& scope_name)
const;
142 std::string GetLink()
const;
144 std::string GetParentLink()
const;
146 const std::string& GetTraceId()
const;
147 const std::string& GetSpanId()
const;
148 const std::string& GetParentId()
const;
162 std::chrono::system_clock::time_point GetStartSystemTime()
const;
165 void AddTags(
const logging::LogExtra&,
utils::InternalTag);
167 void AddNonInheritableTags(
const logging::LogExtra&,
utils::InternalTag);
169 impl::TimeStorage& GetTimeStorage();
172 void LogTo(
logging::impl::TagWriter writer)
const&;
176 struct OptionalDeleter {
177 void operator()(Impl*)
const noexcept;
179 static OptionalDeleter ShouldDelete()
noexcept;
181 static OptionalDeleter DoNotDelete()
noexcept;
184 explicit OptionalDeleter(
bool do_delete) : do_delete(do_delete) {}
186 const bool do_delete;
189 friend class SpanBuilder;
191 explicit Span(std::unique_ptr<Impl, OptionalDeleter>&& pimpl);
193 std::string GetTag(std::string_view tag)
const;
195 std::unique_ptr<Impl, OptionalDeleter> pimpl_;
200struct LogSpanAsLastNonCoro
final {
205 LogSpanAsLastNonCoro span);