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());
45 explicit Span(std::string name,
46 ReferenceType reference_type = ReferenceType::kChild,
48 utils::impl::SourceLocation source_location =
53 explicit Span(Span::Impl& impl);
56 Span(Span&& other)
noexcept;
60 Span& operator=(
const Span&) =
delete;
62 Span& operator=(Span&&) =
delete;
87 static Span
MakeSpan(std::string name, std::string_view trace_id,
88 std::string_view parent_span_id);
98 static Span
MakeSpan(std::string name, std::string_view trace_id,
99 std::string_view parent_span_id, std::string link);
118 Span CreateFollower(std::string name)
const;
136 const std::string& scope_name)
const;
179 std::string GetParentLink()
const;
189 const std::string& GetParentId()
const;
203 std::chrono::system_clock::time_point GetStartSystemTime()
const;
206 void AddTags(
const logging::LogExtra&, utils::InternalTag);
208 void AddNonInheritableTags(
const logging::LogExtra&, utils::InternalTag);
210 impl::TimeStorage& GetTimeStorage();
213 void LogTo(
logging::impl::TagWriter writer)
const&;
217 struct OptionalDeleter {
218 void operator()(Impl*)
const noexcept;
220 static OptionalDeleter ShouldDelete()
noexcept;
222 static OptionalDeleter DoNotDelete()
noexcept;
225 explicit OptionalDeleter(
bool do_delete) : do_delete(do_delete) {}
227 const bool do_delete;
230 friend class SpanBuilder;
233 explicit Span(std::unique_ptr<Impl, OptionalDeleter>&& pimpl);
235 std::string GetTag(std::string_view tag)
const;
237 std::unique_ptr<Impl, OptionalDeleter> pimpl_;
242struct LogSpanAsLastNonCoro
final {
247 LogSpanAsLastNonCoro span);