Checks whether OpenTelemetry tracing is active. This can be useful to avoid unnecessary computation when tracing is inactive.
is_tracing_enabled(tracer = NULL)Tracer object (otel_tracer). It can also be a tracer
name, the instrumentation scope, or NULL for determining the tracer
name automatically. Passed to get_tracer() if not a tracer object.
TRUE is OpenTelemetry tracing is active, FALSE otherwise.
It calls get_tracer() with name and then it calls the tracer's
$is_enabled() method.
Other OpenTelemetry trace API:
Zero Code Instrumentation,
end_span(),
local_active_span(),
start_local_active_span(),
start_span(),
tracing-constants,
with_active_span()
fun <- function() {
if (otel::is_tracing_enabled()) {
xattr <- calculate_some_extra_attributes()
otel::start_local_active_span("fun", attributes = xattr)
}
# ...
}