OpenTelemetry API for R packages and projects
OpenTelemetry is an observability framework. OpenTelemetry is a collection of tools, APIs, and SDKs used to instrument, generate, collect, and export telemetry data such as metrics, logs, and traces, for analysis in order to understand your software’s performance and behavior.
For an introduction to OpenTelemetry, see the OpenTelemetry website docs.
To learn how to instrument your R code, see Getting Started. For project status, installation instructions and more, read on.
Set otel_tracer_name
to the desired tracer name. (See
?otel_tracer_name
.) Then add
otel::start_local_active_span()
calls to the functions you
want to trace:
<- "<package-id>"
otel_tracer_name <- function(...) {
fn <- otel::start_local_active_span("fn")
spn
... }
See Getting Started for details.
Use the otel package as a dependency if you want to instrument your R package or project for OpenTelemetry.
Use the otelsdk package to produce OpenTelemetry output from an R package or project that was instrumented with the otel package.
The current status of the major functional components for OpenTelemetry R is as follows:
Traces | Metrics | Logs |
---|---|---|
Development | Development | Development |
otel and otelsdk support R 3.6.0 and higher on Unix and R 4.3.0 or higher on Windows.
Install otel from CRAN:
# install.packages("pak")
::pak("otel") pak
You can install the development version of otel from GitHub with:
# install.packages("pak")
::pak("r-lib/otel") pak
MIT © Posit, PBC