Class Span
Defined in File span.h
Inheritance Relationships
Derived Types
public opentelemetry::trace::DefaultSpan
(Class DefaultSpan)public opentelemetry::trace::NoopSpan
(Class NoopSpan)
Class Documentation
-
class Span
A Span represents a single operation within a Trace.
Span attributes can be provided:
at span creation time, using Tracer::StartSpan(),
during the span lifetime, using Span::SetAttribute()
Please note that head samplers, in the SDK (opentelemetry::sdk::trace::Sampler), can only make sampling decisions based on data known at span creation time.
When attributes are known early, adding attributes with opentelemetry::trace::Tracer::StartSpan() is preferable.
Attributes added or changed with Span::SetAttribute() can not change a sampler decision.
Likewise, links can be provided:
at span creation time, using Tracer::StartSpan(),
during the span lifetime, using Span::AddLink() or Span::AddLinks().
When links are known early, adding links with opentelemetry::trace::Tracer::StartSpan() is preferable.
Links added with Span::AddLink() or Span::AddLinks() can not change a sampler decision.
Subclassed by opentelemetry::trace::DefaultSpan, opentelemetry::trace::NoopSpan
Public Functions
-
Span() = default
-
virtual ~Span() = default
-
virtual void SetAttribute(nostd::string_view key, const common::AttributeValue &value) noexcept = 0
Sets an attribute on the Span (ABI).
If the Span previously contained a mapping for the key, the old value is replaced.
See comments about sampling in opentelemetry::trace::Span
-
virtual void AddEvent(nostd::string_view name) noexcept = 0
-
virtual void AddEvent(nostd::string_view name, common::SystemTimestamp timestamp) noexcept = 0
-
virtual void AddEvent(nostd::string_view name, common::SystemTimestamp timestamp, const common::KeyValueIterable &attributes) noexcept = 0
-
inline virtual void AddEvent(nostd::string_view name, const common::KeyValueIterable &attributes) noexcept
-
template<class T, nostd::enable_if_t<common::detail::is_key_value_iterable<T>::value>* = nullptr>
inline void AddEvent(nostd::string_view name, common::SystemTimestamp timestamp, const T &attributes) noexcept
-
template<class T, nostd::enable_if_t<common::detail::is_key_value_iterable<T>::value>* = nullptr>
inline void AddEvent(nostd::string_view name, const T &attributes) noexcept
-
inline void AddEvent(nostd::string_view name, common::SystemTimestamp timestamp, std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>> attributes) noexcept
-
inline void AddEvent(nostd::string_view name, std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>> attributes) noexcept
-
virtual void SetStatus(StatusCode code, nostd::string_view description = "") noexcept = 0
-
virtual void UpdateName(nostd::string_view name) noexcept = 0
-
virtual void End(const trace::EndSpanOptions &options = {}) noexcept = 0
Mark the end of the Span. Only the timing of the first End call for a given Span will be recorded, and implementations are free to ignore all further calls.
- Parameters:
options – can be used to manually define span properties like the end timestamp
-
virtual trace::SpanContext GetContext() const noexcept = 0
-
virtual bool IsRecording() const noexcept = 0