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
40 ReferenceType reference_type,
42 utils::impl::SourceLocation source_location = utils::impl::SourceLocation::Current()
52 ReferenceType reference_type = ReferenceType::kChild,
59 explicit Span(Span::Impl& impl);
62 Span(Span&& other)
noexcept;
66 Span& operator=(
const Span&) =
delete;
68 Span& operator=(Span&&) =
delete;
93 static Span
MakeSpan(std::string name, std::string_view trace_id, std::string_view parent_span_id);
104 MakeSpan(std::string name, std::string_view trace_id, std::string_view parent_span_id, std::string link);
122 Span CreateFollower(std::string name)
const;
158 void AddNonInheritableTags(
const logging::LogExtra&);
189 std::string GetParentLink()
const;
199 const std::string& GetParentId()
const;
213 std::chrono::system_clock::time_point GetStartSystemTime()
const;
217 void AddTags(
const logging::LogExtra&,
utils::impl::InternalTag);
220 impl::TimeStorage& GetTimeStorage(
utils::impl::InternalTag);
223 void LogTo(
logging::impl::TagWriter writer)
const&;
227 struct OptionalDeleter {
228 void operator()(Impl*)
const noexcept;
230 static OptionalDeleter ShouldDelete()
noexcept;
232 static OptionalDeleter DoNotDelete()
noexcept;
235 explicit OptionalDeleter(
bool do_delete) : do_delete(do_delete) {}
237 const bool do_delete;
240 friend class SpanBuilder;
243 explicit Span(std::unique_ptr<Impl, OptionalDeleter>&& pimpl);
245 std::string GetTag(std::string_view tag)
const;
247 std::unique_ptr<Impl, OptionalDeleter> pimpl_;
252class DetachLocalSpansScope
final {
254 DetachLocalSpansScope()
noexcept;
255 ~DetachLocalSpansScope();
257 DetachLocalSpansScope(DetachLocalSpansScope&&) =
delete;
258 DetachLocalSpansScope& operator=(DetachLocalSpansScope&&) =
delete;
262 utils::FastPimpl<Impl, 16, 8> impl_;
265struct LogSpanAsLastNoCurrent
final {
269logging::LogHelper& operator<<(
logging::LogHelper& lh, LogSpanAsLastNoCurrent span);