OpenTelemetry API v0.3.1 OpenTelemetry.Span
This module contains macros for Span operations that update the active current Span in the current process. An example of creating an Event and adding it to the current Span:
require OpenTelemetry.Span
...
ecto_event = OpenTelemetry.event("ecto.query", [{"query", query}, {"total_time", total_time}])
OpenTelemetry.Span.add_event(ecto_event)
...
A Span represents a single operation within a trace. Spans can be nested to form a trace tree. Each trace contains a root span, which typically describes the end-to-end latency and, optionally, one or more sub-spans for its sub-operations.
Spans encapsulate:
- The span name
- An immutable SpanContext (
OpenTelemetry.span_ctx/0
) that uniquely identifies the Span - A parent Span in the form of a Span (
OpenTelemetry.span/0
), SpanContext (OpenTelemetry.span_ctx/0
), orundefined
- A start timestamp
- An end timestamp
- An ordered mapping of Attributes (
OpenTelemetry.attributes/0
) - A list of Links to other Spans (
OpenTelemetry.link/0
) - A list of timestamped Events (
OpenTelemetry.event/0
) - A Status (
OpenTelemetry.status/0
)
Link to this section Summary
Functions
Add an event to the currently active Span.
Add a list of events to the currently active Span.
Set an attribute with key and value on the currently active Span.
Add a list of attributes to the currently active Span.
Sets the Status of the currently active Span.
Updates the Span name.
Link to this section Functions
Add an event to the currently active Span.
Add a list of events to the currently active Span.
set_attribute(key, value)
(macro)set_attribute(OpenTelemetry.attribute_key(), OpenTelemetry.attribute_value()) :: boolean()
Set an attribute with key and value on the currently active Span.
set_attributes(attributes)
(macro)set_attributes([OpenTelemetry.attribute()]) :: boolean()
Add a list of attributes to the currently active Span.
Sets the Status of the currently active Span.
If used, this will override the default Span Status, which is Ok
.
Updates the Span name.
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. And often, filtering logic will be implemented before the Span creation for performance reasons. Thus the name update may interfere with this logic.
The function name is called UpdateName to differentiate this function from the regular property setter. 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.