OpenTelemetry Rails Instrumentation
The Rails instrumentation is a community-maintained instrumentation for the Ruby on Rails web-application framework.
How do I get started?
Install the gem using:
gem install opentelemetry-instrumentation-rails
Or, if you use bundler, include opentelemetry-instrumentation-rails
in your Gemfile
.
Version Compatibility
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.24 |
7.x |
~> 0.24 |
Usage
Recommended
To use the Rails instrumentation, call use_all
so it installs all the instrumentation gems.
OpenTelemetry::SDK.configure do |c|
c.use_all
end
Experimental
There is also an experimental Railtie available that will bootstrap the SDK:
# Gemfile
gem "opentelemetry-instrumentation-rails", require: "opentelemetry/instrumentation/rails/railtie"
Configuration options
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 } })
end
Examples
Example usage can be seen in the ./example/trace_demonstration.rb
file here
How can I get involved?
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.
License
The opentelemetry-instrumentation-rails
gem is distributed under the Apache 2.0 license. See LICENSE for more information.