Ruby on Rails OpenTelemetry Instrumentation
Step 1: Install dependenciesβ
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
Step 2: Initialize the OpenTelemetry SDKβ
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!
Step 3: Running your Ruby applicationβ
Now we have to set the following environment variables to export the collected telemetry data for storage and visualization.
OTEL_EXPORTER
: It is the format of exported data. Since SigNoz natively supports otlp so it should be set asotlp
OTEL_SERVICE_NAME
: Name of service(anything you want)OTEL_EXPORTER_OTLP_ENDPOINT
: Specify the endpoint of OTEL collector in formathttp://IP_OF_SIGNOZ:4318
. The OTEL collector comes bundled with SigNoz installation. Since, we installed SigNoz on our local machine, the endpoint isΒhttp://localhost:4318
.OTEL_RESOURCE_ATTRIBUTES
: Pass custom attributes like application name withOTEL_RESOURCE_ATTRIBUTES=application=yourAppName
Using the above mentioned environment variables, run the application:
OTEL_EXPORTER=otlp OTEL_SERVICE_NAME=yourSampleRailsApp OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 OTEL_RESOURCE_ATTRIBUTES=application=sparkapp rails server
Tutorialsβ
Here's a tutorial with step by step guide on how to install SigNoz and start monitoring a sample Ruby on Rails app.
Here's a detailed guide published by our community member Vederis on how to monitor your Ruby on Rails application with OpenTelemetry and SigNoz.
Frequently Asked Questionsβ
How to find what to use in
IP of SigNoz
if I have installed SigNoz in Kubernetes cluster?Based on where you have installed your application and where you have installed SigNoz, you need to find the right value for this. Please use this grid to find the value you should use for
IP of SigNoz
I am sending data from my application to SigNoz, but I don't see any events or graphs in the SigNoz dashboard. What should I do?
This could be because of one of the following reasons:
Your application is generating telemetry data, but not able to connect with SigNoz installation
Please use this troubleshooting guide to find if your application is able to access SigNoz installation and send data to it.
Your application is not actually generating telemetry data
Please check if the application is generating telemetry data first. You can use
Console Exporter
to just print your telemetry data in console first. Join our Slack Community if you need help on how to export your telemetry data in consoleYour SigNoz installation is not running or behind a firewall
Please double check if the pods in SigNoz installation are running fine.
docker ps
orkubectl get pods -n platform
are your friends for this.