Skip to content

Ruby ​

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

Before you start

You need a Traces stream and an ingest key for it. See OpenTelemetry → Before you start.

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_TRACES_ENDPOINT=https://ws.latency.app/v1/telemetry/traces
OTEL_EXPORTER_OTLP_TRACES_HEADERS=authorization=Bearer%20lit_your_traces_key

4. Check it's working ​

Start your app, make a few requests, then open Telemetry in the Console and pick your traces stream.

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