Creates, starts and activates an OpenTelemetry span.
Usually you want this functions instead of start_span(), which does
not activate the new span.
start_local_active_span(
name = NULL,
attributes = NULL,
links = NULL,
options = NULL,
...,
tracer = NULL,
activation_scope = parent.frame(),
end_on_exit = TRUE
)Name of the span. If not specified it will be "<NA>".
Span attributes. OpenTelemetry supports the following
R types as attributes: `character, logical, double, integer.
You may use as_attributes() to convert other R types to
OpenTelemetry attributes.
A named list of links to other spans. Every link must be an OpenTelemetry span (otel_span) object, or a list with a span object as the first element and named span attributes as the rest.
A named list of span options. May include:
start_system_time: Start time in system time.
start_steady_time: Start time using a steady clock.
parent: A parent span or span context. If it is NA, then the
span has no parent and it will be a root span. If it is NULL, then
the current context is used, i.e. the active span, if any.
kind: Span kind, one of span_kinds:
"internal", "server", "client", "producer", "consumer".
Additional arguments are passed to the start_span() method
of the tracer.
A tracer object or the name of the tracer to use, see
get_tracer(). If NULL then default_tracer_name() is used.
The R scope to activate the span for. Defaults to the caller frame.
Whether to also end the span when the activation scope exits.
The new OpenTelemetry span object (of class otel_span), invisibly. See otel_span for information about the returned object.
If end_on_exit is TRUE (the default), then it also ends the span
when the activation scope finishes.
Other OpenTelemetry trace API:
Zero Code Instrumentation,
end_span(),
is_tracing_enabled(),
local_active_span(),
start_span(),
tracing-constants,
with_active_span()
fn1 <- function() {
otel::start_local_active_span("fn1")
fn2()
}
fn2 <- function() {
otel::start_local_active_span("fn2")
}
fn1()