Skip to content

Ruby ​

Automatic traces for Rails, Sinatra, Rack, ActiveRecord, Net::HTTP, Faraday, Redis, Sidekiq and more.

Prerequisites

An OpenTelemetry Stream and an ingest key for that Stream. See OpenTelemetry → Prerequisites.

1. Install ​

bash
bundle add opentelemetry-sdk opentelemetry-exporter-otlp opentelemetry-instrumentation-all

2. Set up the SDK ​

In Rails, add an initializer. For other apps, run this as early as possible at startup:

ruby
# config/initializers/opentelemetry.rb
require 'opentelemetry/sdk'
require 'opentelemetry/exporter/otlp'
require 'opentelemetry/instrumentation/all'

OpenTelemetry::SDK.configure do |c|
  c.use_all
end

3. Configure ​

bash
OTEL_SERVICE_NAME=checkout-api
OTEL_EXPORTER_OTLP_ENDPOINT=https://ws.latency.app/v1/ingest
OTEL_EXPORTER_OTLP_HEADERS=authorization=Bearer%20lit_XXXXXXXXXXX

4. Check it's working ​

Start the app, make a few requests, then open Telemetry in the Console, pick the Stream and choose Traces.

Custom spans ​

ruby
Tracer = OpenTelemetry.tracer_provider.tracer('checkout')

Tracer.in_span('charge-card') do |span|
  span.set_attribute('order.id', order.id)
  charge_card(order)
end

Metrics and logs ​

OpenTelemetry's metrics and logs support for Ruby is still experimental. Until it's stable, send metrics and logs over the HTTP API.

© 2026 Latency Labs LLC