Calls get_default_tracer_provider() to get the default tracer
provider. Then calls its $get_tracer() method to create a new tracer.
get_tracer(
name = NULL,
version = NULL,
schema_url = NULL,
attributes = NULL,
...,
provider = NULL
)Name of the new tracer. If missing, then deduced
automatically using default_tracer_name(). Make sure you read
the manual page of default_tracer_name() before using this argument.
Optional. Specifies the version of the instrumentation
scope if the scope has a version (e.g. R package version).
Example value: "1.0.0".
Optional. Specifies the Schema URL that should be recorded in the emitted telemetry.
Optional. Specifies the instrumentation scope attributes to associate with emitted telemetry.
Additional arguments are passed to the get_tracer()
method of the provider.
Tracer provider to use. If NULL, then it uses
get_default_tracer_provider() to get a tracer provider.
An OpenTelemetry tracer, an otel_tracer object.
Usually you do not need to call this function directly, because
start_local_active_span() calls it for you.
Calling get_tracer() multiple times with the same name (or same
auto-deduced name) will return the same (internal) tracer object.
(Even if the R external pointer objects representing them are
different.)
A tracer is only deleted if its tracer provider is deleted and garbage collected.
Other low level trace API:
get_default_tracer_provider(),
otel_span,
otel_span_context,
otel_tracer,
otel_tracer_provider,
tracer_provider_noop
myfun <- function() {
trc <- otel::get_tracer()
spn <- trc$start_span()
on.exit(otel::end_span(spn), add = TRUE)
otel::local_active_span(spn, end_on_exit = TRUE)
}
myfun()