Our Ruby agent auto-instruments your code so you can start monitoring applications. You can use our launcher, or follow the instructions in this document to complete a basic Ruby agent installation.
If you are using the agent in a Docker container, install the agent within each container.
The Ruby agent's gem is available from rubygems.org as
newrelic_rpm. For applications using Bundler, add this gem to the Gemfile:gem 'newrelic_rpm'
To use Infinite Tracing, the Infinite Tracing gem is also available from rubygems.org as
newrelic-infinite_tracing. For applications using Bundler, additionally include the Infinite Tracing gem in the Gemfile:gem 'newrelic-infinite_tracing'
The next step varies depending on if you are using Rails or Sinatra:
If using Rails or Sinatra
Rails: If you're using Rails 3 or higher, or Rails 2.3 in the recommended configuration, Rails will automatically call
newrelic_rpmto be required during startup of your application.
Sinatra: If you're using Sinatra or another framework, you must manually call
require 'newrelic_rpm'. Additionally, if you're using Infinite Tracing, manually call
Alternately, manually call
Bundler.require, which also enables Infinite Tracing.
If not using Rails or Sinatra
In order to use automatic browser application monitoring and Cross application tracing in a Rack application that does not use Sinatra or Rails, you must manually include additional Rack middlewares provided by the agent. Place the New Relic gem as low in the list as possible, allowing the frameworks above it to be instrumented when the gem initializes.
After installing the agent, you will need to install the
newrelic.yml configuration file, and name your app:
- If you haven't already, create a New Relic account. It's free, forever. Or, sign in.
- From the account dropdown, select Account settings.
- On the Account settings page, look for the Download a clean configuration file section and click the
- Copy the
newrelic.ymlfile into the
configsub-directory of your application.
- Change the default application name to a meaningful name.
Alternatively, you can generate a
newrelic.yml file manually with the following command:
newrelic install --license_key="YOUR_KEY" "My application"
You may also use the
--force option with this command if you need to overwrite an existing
Typically you will install the Ruby agent in your production environment. If you want to try out the Ruby agent in a development or localhost environment, verify in the relevant
environment: block of the
newrelic.yml file that the
monitor_mode config value has been set to
For example, to deploy New Relic in your development environment and still be able to view your app's performance metrics: In the
development: block, set the
monitor_mode config value to
To uninstall the Ruby agent using Bundler, remove
gem 'newrelic_rpm' from your Gemfile. If you are not using Bundler, remove all references to
newrelic_rpm from your
If you're installing the Ruby agent on Rails 2.x, and aren't using Bundler, follow these procedures.
Rails 2.1 - 2.3 without Bundler
Rails earlier than 2.1
New Relic does not officially support Rails versions prior to 2.1. However, if you want to use New Relic for Rails versions 2.0.*, edit
If enabling Infinite Tracing, add the following to the next line in the
If you need more help, check out these support and learning resources:
- Browse the Explorers Hub to get help from the community and join in discussions.
- Find answers on our sites and learn how to use our support portal.
- Run New Relic Diagnostics, our troubleshooting tool for Linux, Windows, and macOS.
- Review New Relic's data security and licenses documentation.