Developer mode

The New Relic Ruby agent includes Developer mode, a built-in user interface for examining details about web transactions in your application. With Developer mode you can examine the library and database calls made by the controller actions as they are invoked on the Rails instance.

The free Developer mode gives you some of the same in-depth transaction visibility you get with New Relic's Transaction Traces feature. However, it works only in a single Rails instance, and it has much higher overhead than the production version. It is not recommended for use beyond a developer's desktop sandbox.

Security considerations

The Ruby agent's Developer mode, which is on by default when the RAILS_ENV == "development", does not communicate with the New Relic site in any way. Pie charts are rendered using Google Charts, which involves an HTTP post of aggregate data.

The Ruby agent's Production mode, which is on by default when the RAILS_ENV == "production" and RAILS_ENV == "staging", does communicate with the New Relic site. For more information, see Security.

Installation

To install Developer mode, install Ruby agent as a plugin or gem. You may also need to set developer_mode to true in your newrelic.yml for the RAILS_ENV in which you are working. Developer mode is on by default only when RAILS_ENV = development.

While a newrelic.yml file will be created as part of the installation, it is not necessary to have a valid license key.

Known issues

Known issues with Developer mode include:

Requires Rails 2.3 or higher

Developer mode in recent agents only works on Rails 2.3 or higher. It is rack based, and earlier versions of the framework did not incorporate rack.

The developer edition installs a middleware in your app that responds to any URL prepended with /newrelic; for example, /newrelic, /newrelic/files/images/foo.png, etc.

In some cases the /newrelic URL gets captured by an earlier middleware. In this situation, disable the Developer mode route and include the middleware yourself:

At the beginning of the file, in config.ru:

require 'newrelic_rpm'
require 'new_relic/rack/developer_mode'
use NewRelic::Rack::DeveloperMode
Incompatible with Pow

Developer mode is not supported from Pow, a zero-config Rack server for Mac OS X.

Using Developer mode

If you run your application on your desktop using thin, WEBrick or something similar, open the URL /newrelic on your server to see the Developer mode user interface.

If you are using Passenger, Unicorn, or other forking application servers on your desktop, you may notice some odd behavior with disappearing data if your application server launches multiple instances. Refer to the Troubleshooting tips, which follow.

screen-ruby-developer-mode-breakdown-chart

Developer Mode Breakdown Chart

Troubleshooting

Troubleshooting tips for Developer mode:

Disappearing requests

If you have this problem with Unicorn or other multi-worker dispatchers, try limiting the number of workers to 1.

Undefined method path for Rack::Request

Some users may see an undefined method path for #<Rack::Request>. If you are using Rails version 2.3.2, then you are mostly likely running into a problem with the way the Rack dependency was defined in the Rails package. Either upgrade to 2.3.3 (or higher), or define Rack version 1.0.1 as a dependency in your Gemfile.

ActiveRecord reloads

Developer mode reloads ActiveRecord method definitions for every reload and reports the time spent defining the methods (such as define_attribute_method). This does not happen in production. To get real results to compare, add the following to the development environment:

  config.cache_classes = true

For more help

Join the discussion about Ruby in the New Relic Online Technical Community! The Technical Community is a public platform to discuss and troubleshoot your New Relic toolset.

If you need additional help, get support at support.newrelic.com.