Installation

Raygun's support for Ruby APM will allow you to profile your Ruby or Ruby on Rails application. Ruby teams can now get end-to-end monitoring with features like detailed trace transactions, dashboards, user experience monitoring and more.

It's as simple as installing our Agent and the appropriate Ruby gem.


Installation instructions for Ruby

The profiler only supports CRuby, also known as Matz's Ruby Interpreter (MRI).

  • 2.5.x
  • 2.6.x
  • 2.7.x
  • 3.0.x
  • 3.1.x

Contact us to support other Ruby versions.

Follow the agent installation instructions for your environment.


Include this gem in your Gemfile:

gem 'raygun-apm'

To avoid profiling test data, only enable profiling for your production environment:

group :production do
  gem 'raygun-apm'
end

Run bundle to install the gem.

Alternatively, install it using rubygems:

gem install raygun-apm

Installation instructions for Ruby on Rails

  • Rails 5.x
  • Rails 6.x

Contact us to support other Ruby on Rails versions.

Follow the agent installation instructions for your environment.


Include this gem in your Gemfile:

gem 'raygun-apm-rails'

To avoid profiling test data, only enable profiling for your production environment:

group :production do
  gem 'raygun-apm-rails'
end

Run bundle to install the gem.

Alternatively, install it using rubygems:

gem install raygun-apm-rails

If you are using Sidekiq, include the Sidekiq gem alongside the Ruby on Rails gem:

group :production do
  gem 'raygun-apm-rails'
  gem 'raygun-apm-sidekiq'
end

Alternatively, install it using rubygems:

gem install raygun-apm-sidekiq

This buildpack installs the Raygun APM agent on your dyno, and starts it after every deploy. To collect data from a Ruby application, you also need the relevant Ruby gem (raygun-apm-rails for a Rails app, raygun-apm otherwise) to your Gemfile.

If you've never deployed your Rails project on Heroku before, please consult the Getting Started on Heroku with Rails guide first to get started.

Navigate to the directory of your project:

cd <YOUR RUBY/RAILS PROJECT>

Initialize a new Heroku project:

heroku create

Add the Ruby buildpack:

heroku buildpacks:add heroku/ruby

Add the Raygun APM buildpack:

heroku buildpacks:add https://github.com/MindscapeHQ/heroku-buildpack-raygun-apm

Add your APM API key to your application configuration:

heroku config:add RAYGUN_API_KEY=<YOUR RAYGUN API KEY>

Commit the changes: e.g.

git commit -am "added heroku set up"

Deploy to Heroku:

git push heroku master


If your application is set up on Heroku with a pipeline that builds a slug on a release or staging environment before deploying it to production, ensure the Raygun APM buildpack is added to the environment where the slug is initially built.

In Heroku Pipelines setups, the slug is built on a release server, then pushed to production. If the Raygun APM buildpack is only applied to the production environment, it will not be part of the pre-built slug, and APM data will not appear.

  1. Add the Raygun APM buildpack to the environment where the slug is built (e.g., staging or release server in your pipeline).
  2. Deploy to confirm the build process includes Raygun APM.

This configuration will ensure APM functionality is included from the slug creation stage, allowing Raygun APM to capture data correctly in production.

note: Heroku users utilizing the Pipelines feature must follow this approach to avoid missing APM data.


Having trouble receiving traces? Please look at our troubleshooting guide.