OpenTelemetry API v1.0.0-rc.2 OpenTelemetry.Tracer
This module contains macros for Tracer operations around the lifecycle of the Spans within a Trace.
The Tracer is able to start a new Span as a child of the active Span of the current process, set a different Span to be the current Span by passing the Span's context, end a Span or run a code block within the context of a newly started span that is ended when the code block completes.
The macros use the Tracer registered to the Application the module using the macro is included in,
assuming OpenTelemetry.register_application_tracer/1
has been called for the Application. If
not then the default Tracer is used.
require OpenTelemetry.Tracer
OpenTelemetry.Tracer.with_span "span-1" do
... do something ...
end
Link to this section Summary
Functions
Add an event to the currently active Span.
Add a list of events to the currently active Span.
Returns the currently active OpenTelemetry.span_ctx/0
.
Returns the OpenTelemetry.span_ctx/0
active in Context ctx
.
End the Span. Sets the end timestamp for the currently active Span. This has no effect on any child Spans that may exist of this Span.
Set an attribute with key and value on the currently active Span.
Add a list of attributes to the currently active Span.
Takes a OpenTelemetry.span_ctx/0
and the Tracer sets it to the currently active Span.
Takes a OpenTelemetry.Ctx.t/0
and the OpenTelemetry.span_ctx/0
and the Tracer sets
it to the current span in the pass Context.
Sets the Status of the currently active Span.
Starts a new span and does not make it the current active span of the current process.
Starts a new span and does not make it the current active span of the current process.
Updates the Span name.
Creates a new span which is set to the currently active Span in the Context of the block.
The Span is ended automatically when the block
completes and the Context is what it was
before the block.
Creates a new span which is set to the currently active Span in the Context of the block.
The Span is ended automatically when the block
completes and the Context is what it was
before the block.
Link to this section Types
start_opts()
start_opts() :: %{ optional(:attributes) => OpenTelemetry.attributes(), optional(:sampler) => term(), optional(:links) => OpenTelemetry.links(), optional(:is_recording) => boolean(), optional(:start_time) => :opentelemetry.timestamp(), optional(:kind) => OpenTelemetry.span_kind() }
Link to this section Functions
add_event(event, attributes)
add_event(OpenTelemetry.event_name(), OpenTelemetry.attributes()) :: boolean()
Add an event to the currently active Span.
Add a list of events to the currently active Span.
current_span_ctx()
Returns the currently active OpenTelemetry.span_ctx/0
.
current_span_ctx(ctx)
Returns the OpenTelemetry.span_ctx/0
active in Context ctx
.
end_span()
End the Span. Sets the end timestamp for the currently active Span. This has no effect on any child Spans that may exist of this Span.
The Span in the current Context has its is_recording
set to false
.
set_attribute(key, value)
set_attribute(OpenTelemetry.attribute_key(), OpenTelemetry.attribute_value()) :: boolean()
Set an attribute with key and value on the currently active Span.
set_attributes(attributes)
set_attributes(OpenTelemetry.attributes()) :: boolean()
Add a list of attributes to the currently active Span.
set_current_span(span_ctx)
Takes a OpenTelemetry.span_ctx/0
and the Tracer sets it to the currently active Span.
set_current_span(ctx, span_ctx)
Takes a OpenTelemetry.Ctx.t/0
and the OpenTelemetry.span_ctx/0
and the Tracer sets
it to the current span in the pass Context.
Sets the Status of the currently active Span.
If used, this will override the default Span Status, which is ok
.
Starts a new span and does not make it the current active span of the current process.
The current active Span is used as the parent of the created Span.
Starts a new span and does not make it the current active span of the current process.
The current active Span is used as the parent of the created Span.
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.
Creates a new span which is set to the currently active Span in the Context of the block.
The Span is ended automatically when the block
completes and the Context is what it was
before the block.
See start_span/2
and end_span/0
.
Creates a new span which is set to the currently active Span in the Context of the block.
The Span is ended automatically when the block
completes and the Context is what it was
before the block.
See start_span/2
and end_span/0
.