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;
152 void AddNonInheritableTags(
const logging::LogExtra&);
183 std::string GetParentLink()
const;
193 const std::string& GetParentId()
const;
207 std::chrono::system_clock::time_point GetStartSystemTime()
const;
211 void AddTags(
const logging::LogExtra&, utils::impl::InternalTag);
214 impl::TimeStorage& GetTimeStorage(utils::impl::InternalTag);
217 void LogTo(
logging::impl::TagWriter writer)
const&;
221 struct OptionalDeleter {
222 void operator()(Impl*)
const noexcept;
224 static OptionalDeleter ShouldDelete()
noexcept;
226 static OptionalDeleter DoNotDelete()
noexcept;
229 explicit OptionalDeleter(
bool do_delete) : do_delete(do_delete) {}
231 const bool do_delete;
234 friend class SpanBuilder;
237 explicit Span(std::unique_ptr<Impl, OptionalDeleter>&& pimpl);
239 std::string GetTag(std::string_view tag)
const;
241 std::unique_ptr<Impl, OptionalDeleter> pimpl_;
246class DetachLocalSpansScope
final {
248 DetachLocalSpansScope()
noexcept;
249 ~DetachLocalSpansScope();
251 DetachLocalSpansScope(DetachLocalSpansScope&&) =
delete;
252 DetachLocalSpansScope& operator=(DetachLocalSpansScope&&) =
delete;
256 utils::FastPimpl<Impl, 16, 8> impl_;
259struct LogSpanAsLastNoCurrent
final {
263logging::LogHelper& operator<<(
logging::LogHelper& lh, LogSpanAsLastNoCurrent span);