Instrumenting Rails with OpenTelemetry


  • Ruby 2.6+

Instrumenting Rails app

git clone
cd example/rails
  • Step 2. Install the required dependencies:
bundle install
  • Step 3. Edit to configure OpenTelemetry to export data to Uptrace:
require 'uptrace'

# copy your project DSN here or use UPTRACE_DSN env var
Uptrace.configure_opentelemetry(dsn: '') do |c|
  c.service_name = 'myservice'
  c.service_version = '1.0.0'
  • Step 4. Edit to instrument the Rails app:
require 'opentelemetry-instrumentation-rails'

Uptrace.configure_opentelemetry(dsn: '') do |c|
  c.use 'OpenTelemetry::Instrumentation::Rails'
UPTRACE_DSN="https://<token><project_id>" rackup

What is next?

By now, you should have a Django app with instrumented views. Next, instrumentopen in new window more operations (for example, database queries) or learn about OpenTelemetry API to create your own instrumentations.