The Rails instrumentation is a community-maintained instrumentation for the Ruby on Rails web-application framework.
Install the gem using:
gem install opentelemetry-instrumentation-railsOr, if you use bundler, include opentelemetry-instrumentation-rails in your Gemfile.
EOL versions of Rails are not supported by the latest version of this instrumentation. If you are using an EOL version of Rails and need an earlier version of this instrumentation, then consider installing and pinning the compatible gem version, e.g.:
gem opentelemetry-instrumentation-rails, "<version>"| Rails Version | Instrumentation Version |
|---|---|
5.2 |
= 0.24.1 |
6.0 |
= 0.28.0 |
6.1 |
= 0.34 |
7.x |
~> 0.34 |
To use the Rails instrumentation, call use_all so it installs all the instrumentation gems.
OpenTelemetry::SDK.configure do |c|
c.use_all
endThere is also an experimental Railtie available that will bootstrap the SDK:
# Gemfile
gem "opentelemetry-instrumentation-rails", require: "opentelemetry/instrumentation/rails/railtie"The Rails instrumentation attempts to mirror the structure of the Ruby on Rails. It is a collection of instrumentation gems for components of Rails such as Action View, Active Record, Action Pack, etc...
You may want to include all of the Rails instrumentation but disable a single instrumentation gem that it includes. Here is an example of how you can disable Active Record when using this instrumentation gem.
OpenTelemetry::SDK.configure do |c|
c.use_all({ 'OpenTelemetry::Instrumentation::ActiveRecord' => { enabled: false } })
endExample usage can be seen in the ./example/trace_demonstration.rb file
The opentelemetry-instrumentation-rails gem source is on github, along with related gems including opentelemetry-api and opentelemetry-sdk.
The OpenTelemetry Ruby gems are maintained by the OpenTelemetry Ruby special interest group (SIG). You can get involved by joining us on our GitHub Discussions, Slack Channel or attending our weekly meeting. See the meeting calendar for dates and times. For more information on this and other language SIGs, see the OpenTelemetry community page.
The opentelemetry-instrumentation-rails gem is distributed under the Apache 2.0 license. See LICENSE for more information.