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/internal_tag.hpp>
14#include <userver/utils/impl/source_location.hpp>
16USERVER_NAMESPACE_BEGIN
38 ReferenceType reference_type,
40 utils::impl::SourceLocation source_location = utils::impl::SourceLocation::Current()
50 ReferenceType reference_type = ReferenceType::kChild,
57 explicit Span(Span::Impl& impl);
60 Span(Span&& other)
noexcept;
64 Span& operator=(
const Span&) =
delete;
66 Span& operator=(Span&&) =
delete;
91 static Span
MakeSpan(std::string name, std::string_view trace_id, std::string_view parent_span_id);
102 MakeSpan(std::string name, std::string_view trace_id, std::string_view parent_span_id, std::string link);
120 Span CreateFollower(std::string name)
const;
156 void AddNonInheritableTags(
const logging::LogExtra&);
187 std::string GetParentLink()
const;
197 const std::string& GetParentId()
const;
211 std::chrono::system_clock::time_point GetStartSystemTime()
const;
215 void AddTags(
const logging::LogExtra&,
utils::impl::InternalTag);
218 impl::TimeStorage& GetTimeStorage(
utils::impl::InternalTag);
221 void LogTo(
logging::impl::TagWriter writer)
const&;
225 struct OptionalDeleter {
226 void operator()(Impl*)
const noexcept;
228 static OptionalDeleter ShouldDelete()
noexcept;
230 static OptionalDeleter DoNotDelete()
noexcept;
233 explicit OptionalDeleter(
bool do_delete) : do_delete(do_delete) {}
235 const bool do_delete;
238 friend class SpanBuilder;
241 explicit Span(std::unique_ptr<Impl, OptionalDeleter>&& pimpl);
243 std::string GetTag(std::string_view tag)
const;
245 std::unique_ptr<Impl, OptionalDeleter> pimpl_;
250class DetachLocalSpansScope
final {
252 DetachLocalSpansScope()
noexcept;
253 ~DetachLocalSpansScope();
255 DetachLocalSpansScope(DetachLocalSpansScope&&) =
delete;
256 DetachLocalSpansScope& operator=(DetachLocalSpansScope&&) =
delete;
260 utils::FastPimpl<Impl, 16, 8> impl_;
263struct LogSpanAsLastNoCurrent
final {
267logging::LogHelper& operator<<(
logging::LogHelper& lh, LogSpanAsLastNoCurrent span);