Learn R Programming

otel (version 0.2.0)

as_attributes: R objects as OpenTelemetry attributes

Description

Convert a list of R objects to a form that is suitable as OpenTelemetry attributes.

Usage

as_attributes(x)

Value

A named list that can be used as the attributes argument to the start_span() method of otel_tracer, the log() method of otel_logger, etc.

If x is not named, or some names are the empty string or NA, then integer numbers as used for the missing or invalid names.

If some elements in x are not of the natively supported R types in OpenTelemetry (character, logical, double, integer), then their printed form is captured using utils::capture.output().

Limits

The number of attributes can be limited with the OTEL_ATTRIBUTE_COUNT_LIMIT environment variable. The default is 128.

The length of the each attribute (vector) can be limited with the OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT environment variable. The default is Inf. Note that this is applied to the length of each attribute as an R vector. E.g. it does not currently limit the number of characters in individual strings.

Arguments

x

A list of R objects, to be used as OpenTelemetry attributes.

Examples

Run this code
as_attributes(list(
  number = 1.0,
  vector = 1:10,
  string = "otel",
  string_vector = letters,
  object = mtcars
))

Run the code above in your browser using DataLab