[−][src]Trait opentelemetry::api::trace::span::Span
Interface for a single operation within a trace.
Required methods
fn add_event_with_timestamp(&mut self, message: String, timestamp: SystemTime)
An API to record events at a specific time in the context of a given Span
.
Events SHOULD preserve the order in which they're set. This will typically match the ordering of the events' timestamps.
Note that the OpenTelemetry project documents certain "standard event names and keys" which have prescribed semantic meanings.
fn add_link(&mut self, link: SpanContext)
An API to add links to a given Span
.
Linked Spans can be from the same or a different trace.
Links SHOULD preserve the order in which they're set.
fn get_context(&self) -> SpanContext
Returns the SpanContext
for the given Span
. The returned value may be used even after
the Span is finished. The returned value MUST be the same for the entire
Span` lifetime.
fn is_recording(&self) -> bool
Returns true if this Span
is recording information like events with the add_event
operation, attributes using set_attributes
, status with set_status
, etc.
This flag SHOULD be used to avoid expensive computations of a Span
attributes or events in
case when a Span
is definitely not recorded. Note that any child span's recording is
determined independently from the value of this flag (typically based on the sampled flag of
a TraceFlag
on SpanContext
).
This flag may be true despite the entire trace being sampled out. This allows to record and process information about the individual Span without sending it to the backend. An example of this scenario may be recording and processing of all incoming requests for the processing and building of SLA/SLO latency charts while sending only a subset - sampled spans - to the backend. See also the sampling section of SDK design.
Users of the API should only access the is_recording
property when instrumenting code and
never access SampledFlag
unless used in context propagators.
fn set_attribute(&mut self, attribute: KeyValue)
An API to set a single Attribute
where the attribute properties are passed
as arguments. To avoid extra allocations some implementations may offer a separate API for
each of the possible value types.
An Attribute
is defined as a KeyValue
pair.
Attributes SHOULD preserve the order in which they're set. Setting an attribute with the same key as an existing attribute SHOULD overwrite the existing attribute's value.
Note that the OpenTelemetry project documents certain "standard attributes" that have prescribed semantic meanings.
fn set_status(&mut self, status: String)
Sets the status of the Span
. If used, this will override the default Span
status, which is OK
.
Only the value of the last call will be recorded, and implementations are free to ignore previous calls.
fn update_name(&mut self, new_name: String)
Updates the Span
's name. After this update, any sampling behavior based on the
name will depend on the implementation.
It is highly discouraged to update the name of a Span
after its creation.
Span
name is often used to group, filter and identify the logical groups of
spans. Often, filtering logic will be implemented before the Span
creation
for performance reasons, and the name update may interfere with this logic.
The method name is called update_name
to differentiate this method from the
regular property. It emphasizes that this operation signifies a
major change for a Span
and may lead to re-calculation of sampling or
filtering decisions made previously depending on the implementation.
fn end(&mut self)
Finishes the Span
.
Implementations MUST ignore all subsequent calls to end
(there might be
exceptions when the tracer is streaming events and has no mutable state
associated with the Span).
Calls to end
a Span MUST not have any effects on child Span
s as they may
still be running and can be ended later.
This API MUST be non-blocking.
fn as_any(&self) -> &dyn Any
Used by global tracer to downcast to specific span type.
Provided methods
fn add_event(&mut self, message: String)
An API to record events in the context of a given Span
.
Events have a time associated with the moment when they are
added to the Span
.
Events SHOULD preserve the order in which they're set. This will typically match the ordering of the events' timestamps.
Note that the OpenTelemetry project documents certain "standard event names and keys" which have prescribed semantic meanings.
Implementors
impl Span for NoopSpan
[src]
fn add_event(&mut self, _message: String)
[src]
Ignores all events
fn add_event_with_timestamp(&mut self, _message: String, _timestamp: SystemTime)
[src]
Ignores all events with timestamps
fn add_link(&mut self, _link: SpanContext)
[src]
Ignores all links
fn get_context(&self) -> SpanContext
[src]
Returns an invalid SpanContext
.
fn is_recording(&self) -> bool
[src]
Returns false, signifying that this span is never recording.
fn set_attribute(&mut self, _attribute: KeyValue)
[src]
Ignores all attributes
fn set_status(&mut self, _status: String)
[src]
Ignores status
fn update_name(&mut self, _new_name: String)
[src]
Ignors name updates
fn end(&mut self)
[src]
Ignores Span
endings.
fn as_any(&self) -> &dyn Any
[src]
Returns self as dyn Any
impl Span for BoxedSpan
[src]
fn add_event_with_timestamp(&mut self, message: String, timestamp: SystemTime)
[src]
Delegates to inner span.0
fn add_link(&mut self, link: SpanContext)
[src]
Delegates to inner span.
fn get_context(&self) -> SpanContext
[src]
Delegates to inner span.
fn is_recording(&self) -> bool
[src]
Delegates to inner span.
fn set_attribute(&mut self, attribute: KeyValue)
[src]
Delegates to inner span.
fn set_status(&mut self, status: String)
[src]
Delegates to inner span.
fn update_name(&mut self, new_name: String)
[src]
Delegates to inner span.
fn end(&mut self)
[src]
Delegates to inner span.
fn as_any(&self) -> &dyn Any
[src]
Returns self as any
impl Span for Span
[src]
fn add_event_with_timestamp(&mut self, message: String, _timestamp: SystemTime)
[src]
Records events at a specific time in the context of a given Span
.
Note that the OpenTelemetry project documents certain "standard event names and keys" which have prescribed semantic meanings.
fn add_link(&mut self, _link: SpanContext)
[src]
Adds links to a given Span
.
Linked Spans can be from the same or a different trace.
fn get_context(&self) -> SpanContext
[src]
Returns the SpanContext
for the given Span
.
fn is_recording(&self) -> bool
[src]
Returns true if this Span
is recording information like events with the add_event
operation, attributes using set_attributes
, status with set_status
, etc.
fn set_attribute(&mut self, attribute: KeyValue)
[src]
Sets a single Attribute
where the attribute properties are passed as arguments.
Note that the OpenTelemetry project documents certain "standard attributes" that have prescribed semantic meanings.
fn set_status(&mut self, _status: String)
[src]
Sets the status of the Span
. If used, this will override the default Span
status, which is OK
.
fn update_name(&mut self, new_name: String)
[src]
Updates the Span
's name.
fn end(&mut self)
[src]
Finishes the span.
fn as_any(&self) -> &dyn Any
[src]
Returns self as any