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);
85 status_ = CExports::CVTSS_Ok;
97 status_ = CExports::CVTSS_Ok;
107 status_ = CExports::CVTSS_Error;
118 statusMessage_ = message;
119 status_ = CExports::CVTSS_Error;
129 [[noreturn]]
void Raise(
const T &error)
131 statusMessage_ = error.what();
132 status_ = CExports::CVTSS_Error;
145 status_ = (code) ? CExports::CVTSS_Error : CExports::CVTSS_Ok;
158 status_ = (res) ? CExports::CVTSS_Ok : CExports::CVTSS_Error;
170 statusMessage_ = statusMessage;
177 const auto &
module = Module::Get();
178 if (!module.WouldTrace())
180 CExports::CVTSPAN handle =
nullptr;
181 CExports::CVTModuleStartSpan(module.Handle(), name.c_str(), handle);
185 Span() noexcept = default;
187 CExports::CVTSpanStatus status_ = CExports::CVTSS_Unset;
188 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:143
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:168
T ReturnBool(T res) noexcept
Set the span status based on boolean interpretation of a result.
Definition span.hpp:156
T Succeed(T &&result)
Return a result and the span status to success.
Definition span.hpp:95
void Fail(const std::string &message) noexcept
Set the span status to fail with a message.
Definition span.hpp:116
void Fail() noexcept
Set the span status to fail.
Definition span.hpp:105
void Succeed() noexcept
Set the span status to success.
Definition span.hpp:83
void Raise(const T &error)
Set the span status to fail and raises an exception.
Definition span.hpp:129
Namespace for telemetry.
Definition attribute_map.hpp:16
Root namespace for the Image Manager interface.
Definition version.hpp:11