4#include "attribute_map.hpp"
18 class Span :
public AttributeMap
46 Span &operator=(
const Span &) =
delete;
49 , statusMessage_(
std::move(other.statusMessage_))
55 Span &operator=(Span &&other)
noexcept
59 AttributeMap::operator=(
std::move(other));
60 statusMessage_ =
std::move(other.statusMessage_);
61 status_ = other.status_;
71 if (status_ == CExports::CVTSS_Unset && std::uncaught_exceptions() > 0)
72 status_ = CExports::CVTSS_Error;
75 CExports::CVTSpanEnd(handle_, status_, (statusMessage_.size()) ? statusMessage_.c_str() :
nullptr);
86 explicit operator bool() const noexcept
88 return handle_ !=
nullptr;
97 status_ = CExports::CVTSS_Ok;
109 status_ = CExports::CVTSS_Ok;
119 status_ = CExports::CVTSS_Error;
130 statusMessage_ = message;
131 status_ = CExports::CVTSS_Error;
141 [[noreturn]]
void Raise(
const T &error)
143 statusMessage_ = error.what();
144 status_ = CExports::CVTSS_Error;
157 status_ = (code) ? CExports::CVTSS_Error : CExports::CVTSS_Ok;
170 status_ = (res) ? CExports::CVTSS_Ok : CExports::CVTSS_Error;
182 statusMessage_ = statusMessage;
189 const auto &
module = Module::Get();
190 if (!module.WouldTrace())
192 CExports::CVTSPAN handle =
nullptr;
193 CExports::CVTModuleStartSpan(module.Handle(), name.c_str(), handle);
197 Span() noexcept = default;
199 CExports::CVTSpanStatus status_ = CExports::CVTSS_Unset;
200 std::
string statusMessage_;
A attribute map for telemetry data.
Definition attribute_map.hpp:32
A span object to report traces.
Definition span.hpp:19
static Span Create(const std::string &name)
Creates a span with the given name.
Definition span.hpp:27
T Return(T code) noexcept
Set the span status based on return code evaluation.
Definition span.hpp:155
static Span Create()
Creates a dummy span.
Definition span.hpp:40
void SetStatusMessage(const std::string &statusMessage) noexcept
Set the status message.
Definition span.hpp:180
T ReturnBool(T res) noexcept
Set the span status based on boolean interpretation of a result.
Definition span.hpp:168
T Succeed(T &&result)
Return a result and the span status to success.
Definition span.hpp:107
void Fail(const std::string &message) noexcept
Set the span status to fail with a message.
Definition span.hpp:128
void Fail() noexcept
Set the span status to fail.
Definition span.hpp:117
void Succeed() noexcept
Set the span status to success.
Definition span.hpp:95
void Raise(const T &error)
Set the span status to fail and raises an exception.
Definition span.hpp:141
Namespace for telemetry.
Definition attribute_map.hpp:16
Root namespace for the Image Manager interface.
Definition version.hpp:11