Calls get_default_tracer_provider()
to get the default tracer
provider. Then calls its $get_tracer()
method to create a new tracer.
Usage
get_tracer(
name = NULL,
version = NULL,
schema_url = NULL,
attributes = NULL,
...,
provider = NULL
)
Arguments
- name
Name of the new tracer. If missing, then deduced automatically using
default_tracer_name()
. Make sure you read the manual page ofdefault_tracer_name()
before using this argument.- version
Optional. Specifies the version of the instrumentation scope if the scope has a version (e.g. R package version). Example value:
"1.0.0"
.- schema_url
Optional. Specifies the Schema URL that should be recorded in the emitted telemetry.
- attributes
Optional. Specifies the instrumentation scope attributes to associate with emitted telemetry.
- ...
Additional arguments are passed to the
get_tracer()
method of the provider.- provider
Tracer provider to use. If
NULL
, then it usesget_default_tracer_provider()
to get a tracer provider.
Value
An OpenTelemetry tracer, an otel_tracer object.
Details
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.
See also
Other low level trace API:
get_default_tracer_provider()
,
otel_span
,
otel_span_context
,
otel_tracer
,
otel_tracer_provider
,
tracer_provider_noop
Examples
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()