Monitor Ruby On Rails performance with OpenTelemetry

OpenTelemetry Rails

OpenTelemetry can be integrated with Ruby on Rails to add observability and monitoring capabilities to your Rails applications.

By integrating OpenTelemetry, you can collect telemetry data, such as distributed traces and metrics, and send it to various backends for analysis and visualization.

What is OpenTelemetry?

OpenTelemetryopen in new window is an open source observability framework that helps developers instrument, generate, collect, and export telemetry data from software applications.

OpenTelemetry provides a unified set of APIs, libraries, and instrumentation tools for capturing and transmitting tracesopen in new window, metricsopen in new window, and logsopen in new window to effectively monitor and troubleshoot distributed systems.

The primary goal of OpenTelemetry is to provide a standardized and vendor-agnostic approach to instrumenting applications for observability. It aims to simplify the process of collecting telemetry data by providing a single, consistent API and providing integration with various OpenTelemetry backendsopen in new window.

What is Ruby on Rails?

Ruby on Rails is a popular open source web application framework written in the Ruby programming language.

Rails follows the Model-View-Controller (MVC) architectural pattern and provides a set of conventions and libraries to simplify and accelerate web development.

Ruby on Rails has gained popularity due to its focus on developer happiness, productivity, and code simplicity. It has been used to build a wide range of applications, from small websites to large, high-traffic platforms.

Rails instrumentation

OpenTelemetry provides instrumentation for various Ruby libraries and frameworks, including Rails. To install OpenTelemetry instrumentation for Ruby on Rails:

gem install opentelemetry-instrumentation-rails

If you use bundler, add opentelemetry-instrumentation-rails to your Gemfile.


By integrating OpenTelemetry with Ruby on Rails, you can gain valuable insight into the performance, behavior, and dependencies of your application. You can monitor and troubleshoot problems, optimize performance, and ensure the reliability of your Rails applications.

To instrument your Rails app, call use with the name of the instrumentation:

require 'uptrace'
require 'opentelemetry-instrumentation-rails'

Uptrace.configure_opentelemetry(dsn: '') do |c|
  c.use 'OpenTelemetry::Instrumentation::Rails'

Alternatively, you can call use_all to install all available instrumentations:

require 'uptrace'
require 'opentelemetry-instrumentation-rails'

Uptrace.configure_opentelemetry(dsn: '') do |c|

See exampleopen in new window for details.

Instrumenting ActiveRecord

Just like with Rails, you need to install ActiveRecord instrumentation:

gem install opentelemetry-instrumentation-active_record

And call use with the name of the instrumentation:

require 'uptrace'
require 'opentelemetry-instrumentation-active_record'

Uptrace.configure_opentelemetry(dsn: '') do |c|
  c.use 'OpenTelemetry::Instrumentation::ActiveRecord'

What is Uptrace?

Uptrace is a distributed tracing toolopen in new window that supports distributed tracing, metrics, and logs. You can use it to monitor applications and troubleshoot issues.

Uptrace Overview

Uptrace comes with an intuitive query builder, rich dashboards, alerting rules with notifications, and integrations for most languages and frameworks.

Uptrace can process billions of spans and metrics on a single server and allows you to monitor your applications at 10x lower cost.

In just a few minutes, you can try Uptrace by visiting the cloud demoopen in new window (no login required) or running it locally with Dockeropen in new window. The source code is available on GitHubopen in new window.

What's next?

OpenTelemetry allows you to instrument specific parts of your code for custom telemetry collection. You can use OpenTelemetry Ruby APIsopen in new window to manually create spans and add custom attributes, events, or metrics to capture additional information.

Last Updated: