This manual page contains the environment variables you can use to configure the otel package. Start with the 'Selecting exporters' section below if you want to produce telemetry data for an instrumented R package.
See also the Environment Variables in the otelsdk package, which is charge of the data collection configuration.
Details
You need set these environment variables when configuring the collection of telemetry data, unless noted otherwise.
Production or Development Environment
OTEL_ENV
By default otel runs in production mode. In production mode otel functions never error. Errors in the telemetry code will not stop the monitored application.
This behavior is not ideal for development, where one would prefer to catch errors early. Set
to run otel in development mode, where otel functions fail on error, make it easier to fix errors.
Selecting Exporters
otel is responsible for selecting the providers to use for traces, logs and metrics. You can use the environment variables below to point the otel functions to the desired providers.
If none of these environment variables are set, then otel will not emit any telemetry data.
See the otelsdk package for configuring the selected providers.
OTEL_TRACES_EXPORTER
The name of the selected tracer provider. See
get_default_tracer_provider()
for the possible values.
OTEL_LOGS_EXPORTER
The name of the selected logger provider. See
get_default_logger_provider()
for the possible values.
OTEL_METRICS_EXPORTER
The name of the selected meter provider. See
get_default_meter_provider()
for the possible values.
Suppressing Instrumentation Scopes (R Packages)
otel has two environment variables to fine tune which instrumentation scopes (i.e. R packages, typically) emit telemetry data. By default, i.e. if neither of these are set, all packages emit telemetry data.
OTEL_R_EMIT_SCOPES
Set this environment variable to a comma separated string of
instrumentation scope names or R package names to restrict telemetry to
these packages only. The name of the instrumentation scope is the same
as the name of the tracer, logger or meter, see default_tracer_name()
.
You can mix package names and instrumentation scope names and you can also use wildcards (globbing). For example the value
OTEL_R_EMIT_SCOPES="org.r-lib.*,dplyr"
selects all packages with an instrumentation scope that starts with
org.r-lib.
and also dplyr.
OTEL_R_SUPPRESS_SCOPES
Set this environment variable to a comma separated string of
instrumentation scope names or R package names to suppress telemetry
data from these packages. The name of the instrumentation scope is the same
as the name of the tracer, logger or meter, see default_tracer_name()
.
You can mix package names and instrumentation scope names and you can also use wildcards (globbing). For example the value
OTEL_R_SUPPRESS_SCOPES="org.r-lib.*,dplyr"
excludes packages with an instrumentation scope that starts with
org.r-lib.
and also dplyr.
Zero Code Instrumentation
otel can instrument R packages for OpenTelemetry data collection
without changing their source code. This relies on changing the code
of the R functions manually using base::trace()
and can be configured
using environment variables.
OTEL_R_INSTRUMENT_PKGS
Set OTEL_R_INSTRUMENT_PKGS
to a comma separated list of packages to
instrument. The automatic instrumentation happens when the otel package
is loaded, so in general it is best to set this environment variable
before loading R.
See also
Environment Variables in otelsdk