powered by
You can use this function to test that OpenTelemetry output is correctly generated for your package or application.
with_otel_record( expr, what = c("traces", "metrics"), tracer_opts = list(), meter_opts = list() )
A list with the output for each output type. Entries:
value: value of expr.
value
expr
traces: the recorded spans, if requested in what.
traces
what
metrics: the recorded metrics measurements, if requested in what.
metrics
Expression to evaluate.
Character vector, type(s) of OpenTelemetry output to collect.
Named list of options to pass to the tracer provider.
Named list of options to pass to the meter provider.
It evaluates the supplied expression, collects OpenTelemetry output from it and returns it.
Note: with_otel_record() cannot record logs yet.
with_otel_record()
with_otel_record() uses tracer_provider_memory and meter_provider_memory internally.
spns <- with_otel_record({ trc <- otel::get_tracer("mytracer") spn1 <- trc$start_local_active_span() spn2 <- trc$start_local_active_span("my") spn2$end() spn1$end() NULL }) spns
Run the code above in your browser using DataLab