Ruby on Rails

Send OpenTelemetry traces from any Ruby or Rails app to Sophonz using the official opentelemetry-ruby gems — no Sophonz package required.

There is no sophonz gem, and you don't need one. Sophonz's collector speaks standard OTLP, so any Ruby or Rails app can send it traces using the official opentelemetry-ruby gems, one Rails initializer, and environment variables.

What you get

  • The official Ruby SDK — opentelemetry-sdk + opentelemetry-exporter-otlp, which reads the standard OTEL_EXPORTER_OTLP_* environment variables automatically once the exporter gem is loaded.
  • Automatic instrumentation for your whole stack via opentelemetry-instrumentation-all — one call, c.use_all, enables every instrumentation gem currently installed: Rails' own controller/view spans, Rack, ActiveRecord/pg/mysql2, Faraday/Net::HTTP outgoing calls, Sidekiq, Redis, and more.
  • No monkey-patching to write yourself — instrumentation hooks into Rails through the same ActiveSupport::Notifications events and Rack middleware Rails already uses.

How it works

  1. Add the SDK, OTLP exporter, and instrumentation gems to your Gemfile.
  2. Create one Rails initializer that calls OpenTelemetry::SDK.configure { |c| c.use_all }.
  3. Set environment variables for the collector endpoint, protocol, headers, and your service's identity.

Because Rails auto-requires every gem in the Gemfile on boot (Bundler.require), the OTLP exporter is already loaded by the time your initializer runs — OpenTelemetry::SDK.configure picks it up as the default trace exporter with no extra wiring.

CAUTION — Telemetry without a valid service.key is dropped silently

Sophonz's collector runs in enforce mode: it accepts the OTLP payload over the wire but silently drops anything that doesn't carry a resolvable service.key resource attribute. There's no error in your app and no rejected request — the console will simply stay empty. Double-check OTEL_RESOURCE_ATTRIBUTES (and OTEL_EXPORTER_OTLP_HEADERS) before assuming something else is broken.

TIP — Where to next

Head to Installation for the exact Gemfile entries, the initializer, environment variable table, and Rails-specific notes.