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