Ruby on Rails OpenTelemetry Instrumentation
Send Traces to SigNoz Cloud
Based on your application environment, you can choose the setup below to send traces to SigNoz Cloud.
- VM
- Kubernetes
From VMs, there are two ways to send data to SigNoz Cloud.
Send traces directly to SigNoz Cloud
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
Run the application using the below:
OTEL_EXPORTER=otlp \
OTEL_SERVICE_NAME=<service_name> \
OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.{region}.signoz.cloud:443 \
OTEL_EXPORTER_OTLP_HEADERS=signoz-access-token=SIGNOZ_INGESTION_KEY \
rails server
<service_name>
: Name of service. For example,sampleRailsApp
SIGNOZ_INGESTION_KEY
: The ingestion key sent by SigNoz over email. It can also be found in thesettings
section of your SigNoz Cloud UI.
Depending on the choice of your region for SigNoz cloud, the ingest endpoint will vary according to this table.
Region | Endpoint |
---|---|
US | ingest.us.signoz.cloud:443 |
IN | ingest.in.signoz.cloud:443 |
EU | ingest.eu.signoz.cloud:443 |
Send traces via OTel Collector binary
OTel Collector binary helps to collect logs, hostmetrics, resource and infra attributes. It is recommended to install Otel Collector binary to collect and send traces to SigNoz cloud. You can correlate signals and have rich contextual data through this way.
You can find instructions to install OTel Collector binary here in your VM. Once you are done setting up your OTel Collector binary, you can follow the below steps for instrumenting your Ruby on Rails application.
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
Run the application using the below:
OTEL_EXPORTER=otlp \
OTEL_SERVICE_NAME=<service_name> \
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 \
rails server
<service_name>
: Name of service. For example,sampleRailsApp
In case you have OtelCollector Agent in different VM, replace localhost:4318 with <IP Address of the VM>:4318
.
For Ruby on Rails application deployed on Kubernetes, you need to install OTel Collector agent in your k8s infra to collect and send traces to SigNoz Cloud. You can find the instructions to install OTel Collector agent here.
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
Run the application using the below:
OTEL_EXPORTER=otlp \
OTEL_SERVICE_NAME=<service_name> \
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 \
rails server
<service_name>
: Name of service. For example,sampleRailsApp
Send Traces to Self-Hosted SigNoz
You can follow these steps to send your traces directly to your Self-Host SigNoz instance.
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
Run the application using the below:
OTEL_EXPORTER=otlp \
OTEL_SERVICE_NAME=<service_name> \
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 \
rails server
<service_name>
: Name of service. For example,sampleRailsApp
In case you have OtelCollector Agent in different VM, replace localhost:4318 with <IP Address of the VM>:4318
.
Tutorials
Here's a tutorial with step by step guide on how to install SigNoz and start monitoring a sample Ruby on Rails app.
Sample Ruby on Rails application
We have included a sample Ruby on Rails application with README.md at Sample Rails App Github Repo.
Feel free to use this repo to test out OpenTelemetry instrumentation and how to send telemetry data to 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.