Ruby

The Dash0 distribution of the OpenTelemetry Ruby SDK, as a DEB and RPM package.

The Dash0 distribution of the OpenTelemetry Ruby SDK, packaged so the OpenTelemetry injector can load it into Ruby processes on a host.

Compatibility

RequirementSupported
Ruby3.3 or later
Architecturesamd64 and arm64
Distribution requirementsRequirements

Setup with the injector

This is the recommended setup: the injector instruments every Ruby process on the host when it starts, without changes to how you start your applications. There are two ways to install it.

With dash0-opentelemetry, install the metapackage. It brings the injector, the keyring and, as recommended packages, the language packages for all runtimes, Ruby included.

On Debian or Ubuntu:

sudo apt-get install dash0-opentelemetry

On Fedora, RHEL or Amazon Linux 2023:

sudo dnf install dash0-opentelemetry

With only the packages you need, install this package and the injector by name.

On Debian or Ubuntu:

sudo apt-get install dash0-injector dash0-ruby-autoinstrumentation

On Fedora, RHEL or Amazon Linux 2023:

sudo dnf install dash0-injector dash0-ruby-autoinstrumentation

In both cases, the package's drop-in at /etc/opentelemetry/injector/conf.d/ruby.conf tells the injector where the tree is. The injector then adds -r /usr/lib/opentelemetry/ruby/glibc/opentelemetry-auto-instrumentation.rb to RUBYOPT, and sets OTEL_RUBY_ADDITIONAL_GEM_PATH, for every Ruby process that starts, and applies default_env.conf to it. Ruby processes that are already running are instrumented only after they restart.

Then set the endpoint and the auth token in default_env.conf, as described under Configuration.

Setup without the injector

Install only this package.

On Debian or Ubuntu:

sudo apt-get install dash0-ruby-autoinstrumentation

On Fedora, RHEL or Amazon Linux 2023:

sudo dnf install dash0-ruby-autoinstrumentation

On its own, the package instruments nothing. It only suggests the injector, and apt and dnf do not install suggested packages. Load the instrumentation yourself when you start the process:

RUBYOPT="-r /usr/lib/opentelemetry/ruby/glibc/opentelemetry-auto-instrumentation.rb" \
  OTEL_RUBY_ADDITIONAL_GEM_PATH=/usr/lib/opentelemetry/ruby/glibc \
  ruby app.rb

Without the injector, default_env.conf is not applied: set the endpoint and the auth token in the environment of the process instead, as described under Configuration.

Configuration

All setups need the same settings, as environment variables:

VariableSets
OTEL_EXPORTER_OTLP_ENDPOINTThe Dash0 OTLP endpoint to send telemetry to
OTEL_EXPORTER_OTLP_HEADERSThe auth token and the dataset
OTEL_SERVICE_NAMEOptional: the service name, which otherwise is derived from the application; see How the service name is chosen

With the injector, set them in /etc/opentelemetry/injector/default_env.conf, which the injector applies to every process it instruments:

OTEL_EXPORTER_OTLP_ENDPOINT=https://ingress.eu-west-1.aws.dash0.com
OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer%20auth_...,Dash0-Dataset=default

Without the injector, set them in the environment of the process, for example in the [Service] section of its systemd unit:

Environment=OTEL_EXPORTER_OTLP_ENDPOINT=https://ingress.eu-west-1.aws.dash0.com
Environment=OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer%20auth_...,Dash0-Dataset=default

In both setups, the declarative configuration file this package ships reads these variables, so they are the only settings most hosts need.

Note that white spaces in OTEL_EXPORTER_OTLP_HEADERS, like in Bearer <token>, must be written %20. Set the endpoint without a trailing slash, since the signal paths such as /v1/traces are appended to it.

A variable in default_env.conf replaces the value a process sets itself, so set OTEL_SERVICE_NAME and other per-application settings in the environment of the application, not in default_env.conf.

DASH0_OTEL_COLLECTOR_BASE_URL is the endpoint when OTEL_EXPORTER_OTLP_ENDPOINT is unset or empty, as in the other Dash0 distributions.

DASH0_DISABLE=true leaves processes uninstrumented without uninstalling the package.

With the injector, the DASH0_ variables reach the process only through dash0-injector, because upstream's opentelemetry-injector forwards only OTEL_-prefixed names.

Declarative configuration

This package ships /etc/opentelemetry/ruby/otel-config.yaml, an OpenTelemetry declarative configuration file. The distribution reads it whenever OTEL_CONFIG_FILE is unset or empty, so it configures every instrumented Ruby process by default. Configuration on the overview describes how to use a file of your own, the propagators every shipped file declares, and what happens to an edited file on upgrade and on removal.

The file uses OpenTelemetry declarative configuration , the standard YAML configuration format of the OpenTelemetry project, whose schema is defined in open-telemetry/opentelemetry-configuration . ${VARIABLE:-default} takes the value of an environment variable, with a default for when it is unset. This excerpt of the shipped file shows the propagators, the resource detectors and the export of traces; metrics and logs are exported in the same way:

file_format: "1.0"
propagator:
  composite:
    - tracecontext: {}
    - baggage: {}
    - xray: {}
resource:
  detection/development:
    detectors:
      - container: {}
      - dash0_distribution: {}
      - dash0_service_name: {}
      - dash0_kubernetes: {}
  attributes_list: ${OTEL_RESOURCE_ATTRIBUTES:-}
tracer_provider:
  processors:
    - batch:
        exporter:
          otlp_http:
            endpoint: ${OTEL_EXPORTER_OTLP_ENDPOINT:-http://localhost:4318}/v1/traces
            headers_list: ${OTEL_EXPORTER_OTLP_HEADERS:-}
            compression: ${OTEL_EXPORTER_OTLP_COMPRESSION:-none}

Supported environment variables

With a configuration file in effect, the file is the whole SDK configuration. The shipped file interpolates these, so default_env.conf stays the one place to set them:

VariableDefault in the file
OTEL_EXPORTER_OTLP_ENDPOINThttp://localhost:4318
OTEL_EXPORTER_OTLP_HEADERSempty
OTEL_EXPORTER_OTLP_COMPRESSIONnone
OTEL_RESOURCE_ATTRIBUTESempty

A configuration file of your own has to carry the same interpolations to keep them.

OTEL_SERVICE_NAME and DASH0_AUTOMATIC_SERVICE_NAME keep working through the dash0_service_name detector the file lists. DASH0_OTEL_COLLECTOR_BASE_URL keeps working as the default for OTEL_EXPORTER_OTLP_ENDPOINT. DASH0_DISABLE applies in either mode.

Unsupported environment variables

  • Every other OTEL_ variable, such as OTEL_METRIC_EXPORT_INTERVAL, unless the file interpolates it.
  • OTEL_PROPAGATORS. Edit the file's propagator list instead.
  • OTEL_SDK_DISABLED. Use DASH0_DISABLE instead.
  • The DASH0_ switches that configure the SDK, such as DASH0_DEBUG_PRINT_SPANS.

Resource detectors

The shipped file lists the upstream container detector, and the distribution's dash0_distribution, dash0_service_name and dash0_kubernetes. The Ruby SDK has no host, os, process or service detectors to add. Resource detection lists the detectors it has, and what each one adds.

Resource attributes

Every instrumented process reports the package it came from:

AttributeValue
dash0.package.namedash0-ruby-autoinstrumentation
dash0.package.versionThe installed package version, packaging revision included

The dash0.package.* attributes are added to OTEL_RESOURCE_ATTRIBUTES before the SDK starts, and are withdrawn again if the distribution stands down, so a process the package did not instrument is not labelled as though it had been.

A configuration file of your own keeps them only if it reads OTEL_RESOURCE_ATTRIBUTES through attributes_list, as the shipped file does.

The distribution adds the other resource attributes, such as service.name and telemetry.distro.*. Resource detection in the distribution docs describes them, and how the service name is chosen, with and without a configuration file.

Conditional instrumentation

The application keeps running in every case below, without telemetry. The distribution writes one line to stderr, starting with [Dash0 OpenTelemetry Distribution]. The OpenTelemetry SDK's own messages go to stdout.

  • DASH0_DISABLE=true.
  • Ruby older than 3.3.
  • The OpenTelemetry SDK already loaded: when the application has loaded opentelemetry/sdk before the distribution, it stands down to avoid double instrumentation.
  • No endpoint without a configuration file: neither OTEL_EXPORTER_OTLP_ENDPOINT nor DASH0_OTEL_COLLECTOR_BASE_URL is set, and no configuration file is in effect.
  • A configuration file that cannot be loaded: the line says Initialization failed: could not load the configuration file.
  • OTEL_SDK_DISABLED=true without a configuration file. With a configuration file it has no effect; use DASH0_DISABLE.
  • The package cannot load the distribution: the entry file reports the failure on stderr and never raises.

With the injector, the injector itself logs why it skipped a process on stderr with OTEL_INJECTOR_LOG_LEVEL=info. See the Injector page.

Installed files

PathPurpose
/usr/lib/opentelemetry/ruby/glibc/opentelemetry-auto-instrumentation.rbThe entry file, loaded with ruby -r
/usr/lib/opentelemetry/ruby/glibc/gems/The distribution and its gems
/etc/opentelemetry/injector/conf.d/ruby.confTells the injector where the tree is
/etc/opentelemetry/ruby/otel-config.yamlThe declarative configuration file, read whenever OTEL_CONFIG_FILE is unset or empty; a conffile, so an edited copy is kept on upgrade
/usr/share/man/man8/opentelemetry-ruby.8.gzThe manual page, for man opentelemetry-ruby
/usr/share/doc/dash0-ruby-autoinstrumentation/README.mdThe installed copy of this page
/usr/share/doc/dash0-ruby-autoinstrumentation/copyrightThe license statement and the notice, DEB only
/usr/share/licenses/dash0-ruby-autoinstrumentation/LICENSEThe license, RPM only
/usr/share/licenses/dash0-ruby-autoinstrumentation/NOTICEThe notice, RPM only

Local overrides belong in a conf.d file that sorts after the package-managed one. The injector reads conf.d in byte order and the last setting wins, so a digit prefix such as 99- sorts before ruby.conf; use a name such as zz-local-ruby.conf. Edits to ruby.conf itself are replaced on upgrade.

Dependencies

PackageRelationWhy
dash0-keyringDependsEvery Dash0 package depends on it, so the signing certificate is owned by a package that upgrades it
dash0-injectorSuggestsInstruments processes with this package; apt and dnf do not install suggested packages, so install the injector by name, as described under Setup with the injector
opentelemetry-ruby-autoinstrumentationConflicts, and Replaces on DEB or Obsoletes on RPMTakes the place of an upstream Ruby package, which the OpenTelemetry project does not publish yet

Versioning

The package version is the version of the bundled distribution, followed by a packaging revision: 0.2.1-1 is the first package built from distribution 0.2.1, 0.2.1-2 a later package built from the same distribution. On RPM distributions the revision is the Release field, so rpm -q shows 0.2.1-1 as version 0.2.1, release 1.

Reverting to the upstream package

The OpenTelemetry project publishes no Ruby package yet, so there is no upstream package to revert to. To stop instrumenting Ruby processes, set DASH0_DISABLE=true, or remove this package.

Source

https://github.com/dash0hq/opentelemetry-ruby-distribution 

Last updated: