183 const std::map<std::string, attribute_value>&
attributes)
219 [[nodiscard]]
auto is_ended() const noexcept ->
bool;
231 [[nodiscard]] auto
name() const noexcept -> const std::
string&;
255 [[nodiscard]] auto
attributes() const noexcept
262 [[nodiscard]] auto
events() const noexcept -> const std::vector<
span_event>&;
268 [[nodiscard]] auto
start_time() const noexcept
269 -> std::chrono::steady_clock::time_point;
275 [[nodiscard]] auto
end_time() const noexcept
276 -> std::chrono::steady_clock::time_point;
282 [[nodiscard]] auto
duration() const noexcept -> std::chrono::nanoseconds;
305#define NETWORK_TRACE_SPAN(name) \
306 auto _span = ::kcenon::network::tracing::trace_context::create_span(name)
311#define NETWORK_TRACE_CLIENT_SPAN(name) \
312 auto _span = ::kcenon::network::tracing::span( \
313 name, ::kcenon::network::tracing::trace_context::current().is_valid() \
314 ? ::kcenon::network::tracing::trace_context::current() \
315 .create_child_span(name) \
317 : ::kcenon::network::tracing::trace_context(), \
318 ::kcenon::network::tracing::span_kind::client)
323#define NETWORK_TRACE_SERVER_SPAN(name) \
324 auto _span = ::kcenon::network::tracing::span( \
325 name, ::kcenon::network::tracing::trace_context::current().is_valid() \
326 ? ::kcenon::network::tracing::trace_context::current() \
327 .create_child_span(name) \
329 : ::kcenon::network::tracing::trace_context(), \
330 ::kcenon::network::tracing::span_kind::server)
RAII span for distributed tracing.
auto status() const noexcept -> span_status
Get the span status.
span(const span &)=delete
auto is_ended() const noexcept -> bool
Check if the span has ended.
auto start_time() const noexcept -> std::chrono::steady_clock::time_point
Get the span start time.
auto attributes() const noexcept -> const std::map< std::string, attribute_value > &
Get the span attributes.
auto set_attribute(std::string_view key, std::string_view value) -> span &
Set a string attribute.
auto kind() const noexcept -> span_kind
Get the span kind.
span(std::string_view name, trace_context ctx, span_kind kind=span_kind::internal)
Construct a new span.
auto add_event(std::string_view name) -> span &
Add an event to the span.
auto set_error(std::string_view message) -> span &
Set error status with message.
auto status_description() const noexcept -> const std::string &
Get the status description.
auto context() const noexcept -> const trace_context &
Get the trace context for this span.
auto name() const noexcept -> const std::string &
Get the span name.
auto operator=(const span &) -> span &=delete
~span()
Destructor - automatically ends the span if not ended.
auto events() const noexcept -> const std::vector< span_event > &
Get the span events.
auto set_status(span_status status) -> span &
Set the span status.
auto duration() const noexcept -> std::chrono::nanoseconds
Get the span duration.
void end()
Manually end the span.
std::unique_ptr< impl > impl_
auto end_time() const noexcept -> std::chrono::steady_clock::time_point
Get the span end time.
Immutable trace context for distributed tracing.
std::variant< std::string, int64_t, double, bool > attribute_value
Attribute value type (supports string, int64, double, bool)
span_kind
Span kind following OpenTelemetry conventions.
@ consumer
Message consumer (e.g., queue subscriber)
@ client
Client-side request.
@ server
Server-side handling of a request.
@ internal
Default, represents internal operations.
@ producer
Message producer (e.g., queue publisher)
span_status
Span status codes following OpenTelemetry conventions.
@ unset
Default status, span completed without explicit status.
Internal implementation structure for span.
Span event (timestamped annotation)
std::chrono::steady_clock::time_point timestamp
std::map< std::string, attribute_value > attributes
Distributed tracing context for OpenTelemetry-compatible tracing.