Monitor and observe Ruby (on Rails) apps.
Instrumenting your Ruby application to generate traces, logs, and metrics is a powerful way to gain deep insights into its behavior and performance. For example, to get a clearer picture of your Ruby on Rails apps and the database statements generated through Active Record. By adding instrumentation, you enable your application to emit valuable data that can be used for monitoring, troubleshooting, and optimization.
Dash0 supports automatic instrumentation of Ruby applications through OpenTelemetry's open-source and vendor-agnostic gems.
OpenTelemetry comes with ready-made auto-instrumentation gems for Ruby that will kickstart your observability journey. Let's start by installing them:
The OpenTelemetry SDK needs to be initialized on startup before your application's and framework's code. Execute
the following code as the first thing within your app. Within Rails you can achieve this by putting this code into
a file called config/initializers/opentelemetry.rb
.
The auto-instrumentation in OpenTelemetry can be configured using environment variables.
1. Specify the application service name:
Replace my-first-observable-ruby-service with a meaningful name that identifies your application.
2. Set up the data export endpoint and authorization token:
Note: You can specify which dataset to send data to by adding the Dash0-Dataset
header. For example:
For more information, see the dataset documentation.
To understand which libraries are automatically instrumented by this package, please refer to the opentelemetry-ruby-contrib.