|
A11 (C++ runtime)
Native C++ implementation of the A11 action and streaming runtime
|
Move-only RAII handle to one action, session, or transport span. More...
#include <cpp/a11/obs/span.h>
Classes | |
| struct | Impl |
Public Member Functions | |
| Span () noexcept=default | |
| ~Span () | |
| Span (Span &&other) noexcept | |
| Transfer ownership without ending the span. | |
| Span & | operator= (Span &&other) noexcept |
End the currently owned span, then transfer other. | |
| Span (const Span &)=delete | |
| Span & | operator= (const Span &)=delete |
| bool | IsRecording () const noexcept |
| Whether this handle currently records attributes and events. | |
| std::string | TraceIdHex () const |
| Return the 32-character trace id, or empty when inactive. | |
| std::string | SpanIdHex () const |
| Return the 16-character span id, or empty when inactive. | |
| void | SetAttribute (std::string_view key, std::string_view value) |
| Set or replace a string attribute on the live span. | |
| void | SetAttribute (std::string_view key, const char *value) |
| Set or replace a C-string attribute on the live span. | |
| void | SetAttribute (std::string_view key, std::int64_t value) |
| Set or replace an integer attribute on the live span. | |
| void | SetAttribute (std::string_view key, bool value) |
| Set or replace a boolean attribute on the live span. | |
| void | SetAttribute (std::string_view key, double value) |
| Set or replace a floating-point attribute on the live span. | |
| void | AddEvent (std::string_view name) |
| Record a named point-in-time event. | |
| void | AddEvent (std::string_view name, const std::vector< std::pair< std::string, std::string > > &attributes) |
| Record an event with string attributes. | |
| void | SetStatus (const absl::Status &status) |
| Map an A11 operation status onto the span's OTel outcome. | |
| void | SetStatus (SpanStatus status, std::string_view description={}) |
Set an explicit OTel outcome; description explains kError. | |
| void | UpdateName (std::string_view name) |
| Replace the name that will be exported when the span ends. | |
| void | End () noexcept |
| Finish the span and release its implementation; safe to call repeatedly. | |
| absl::Status | InjectContext (data::ByteMap &headers) const |
| Inject trace context and inherited baggage into reserved A11 headers. | |
Friends | |
| class | Tracer |
Move-only RAII handle to one action, session, or transport span.
A default-constructed or moved-from Span is inactive: IsRecording() is false and every mutator is a no-op. Tracer also returns an inactive span when tracing is not configured, so agent runtime call sites need no feature branches. End() is idempotent, and destruction ends a live span.
OpenTelemetry types remain hidden in fixed inline storage so this public header does not expose the SDK or allocate a separate pImpl for every span.
|
defaultnoexcept |
| a11::obs::Span::~Span | ( | ) |
|
noexcept |
Transfer ownership without ending the span.
| void a11::obs::Span::AddEvent | ( | std::string_view | name | ) |
Record a named point-in-time event.
| void a11::obs::Span::AddEvent | ( | std::string_view | name, |
| const std::vector< std::pair< std::string, std::string > > & | attributes | ||
| ) |
Record an event with string attributes.
|
noexcept |
Finish the span and release its implementation; safe to call repeatedly.
| absl::Status a11::obs::Span::InjectContext | ( | data::ByteMap & | headers | ) | const |
Inject trace context and inherited baggage into reserved A11 headers.
|
noexcept |
Whether this handle currently records attributes and events.
End the currently owned span, then transfer other.
Set or replace a boolean attribute on the live span.
Set or replace a C-string attribute on the live span.
Set or replace a floating-point attribute on the live span.
| void a11::obs::Span::SetAttribute | ( | std::string_view | key, |
| std::int64_t | value | ||
| ) |
Set or replace an integer attribute on the live span.
| void a11::obs::Span::SetAttribute | ( | std::string_view | key, |
| std::string_view | value | ||
| ) |
Set or replace a string attribute on the live span.
Map an A11 operation status onto the span's OTel outcome.
| void a11::obs::Span::SetStatus | ( | SpanStatus | status, |
| std::string_view | description = {} |
||
| ) |
Set an explicit OTel outcome; description explains kError.
| std::string a11::obs::Span::SpanIdHex | ( | ) | const |
Return the 16-character span id, or empty when inactive.
| std::string a11::obs::Span::TraceIdHex | ( | ) | const |
Return the 32-character trace id, or empty when inactive.
| void a11::obs::Span::UpdateName | ( | std::string_view | name | ) |
Replace the name that will be exported when the span ends.