This guide provides step-by-step instructions for setting up OpenTelemetry (OTel) instrumentation in your Ruby On Rails applications to enable comprehensive observability. OpenTelemetry is an open-source framework that helps you collect telemetry data—such as traces, metrics, and logs—from your app to monitor its performance and health.
Once your telemetry data is captured, you can configure an exporter to send it directly to Atatus for advanced monitoring and insights.
The process of setting up OpenTelemetry in Ruby On Rails involves three key steps:
Instrumenting Your Ruby On Rails Application: Add the necessary OpenTelemetry components to your Ruby On Rails app for trace and metric collection.
Configuring the Exporter: Set up the exporter to send your telemetry data to Atatus.
Validating the Setup: Verify that the configuration is working and that your data is being correctly sent to Atatus.
Sending Telemetry Data to Atatus in Two Ways
Send Telemetry Traces to Atatus
Send Traces Using the OTel Collector Binary
Send Telemetry Traces to Atatus
Install dependencies related to OpenTelemetry SDK and exporter using gem.
gem install opentelemetry-sdk gem install opentelemetry-exporter-otlp gem install opentelemetry-instrumentation-all
Include the required packages into your gemfile.
gem 'opentelemetry-sdk' gem 'opentelemetry-exporter-otlp' gem 'opentelemetry-instrumentation-all'
Run the bundle install command:
bundle install
Initialize the otel sdk by adding below lines to
config/environment.rb
of your Ruby on Rails application.require 'opentelemetry/sdk' require_relative 'application' OpenTelemetry::SDK.configure do |c| c.use_all end Rails.application.initialize!
Run your application
OTEL_EXPORTER=otlp \ OTEL_RESOURCE_ATTRIBUTES=service.name=<service_name> \ OTEL_EXPORTER_OTLP_ENDPOINT="https://otel-rx.atatus.com:443" \ OTEL_EXPORTER_OTLP_HEADERS="api-key=ATATUS_INGESTION_KEY" \ rails server
You can get the ATATUS_INGESTION_KEY
from Settings -> Account Settings -> API Keys in Atatus dashboard.
Send Traces Using the OTel Collector Binary
To collect and send traces to Atatus, it's recommended to install the OpenTelemetry (OTel) Collector binary. The OTel Collector helps gather logs, host metrics, resource, and infrastructure attributes, enabling richer contextual data and easier signal correlation.
For detailed instructions on setting up the OTel Collector binary on your VM, please refer to the official installation guide. Once the Collector is up and running, you can proceed with instrumenting your Java application to start sending telemetry data to Atatus.
Install dependencies related to OpenTelemetry SDK and exporter using gem.
gem install opentelemetry-sdk gem install opentelemetry-exporter-otlp gem install opentelemetry-instrumentation-all
Include the required packages into your gemfile.
gem 'opentelemetry-sdk' gem 'opentelemetry-exporter-otlp' gem 'opentelemetry-instrumentation-all'
Run the bundle install command:
bundle install
Initialize the otel sdk by adding below lines to
config/environment.rb
of your Ruby on Rails application.require 'opentelemetry/sdk' require_relative 'application' OpenTelemetry::SDK.configure do |c| c.use_all end Rails.application.initialize!
Run your application
OTEL_EXPORTER=otlp \ OTEL_RESOURCE_ATTRIBUTES=service.name=<service_name> \ OTEL_EXPORTER_OTLP_ENDPOINT="http://127.0.0.1:4318" \ rails server