No data with Unicorn

Problem

If you do not see data with Unicorn, follow these procedures based on your New Relic Ruby agent version.

Solution

If you are using Ruby agent version 3.8.0 or higher, you should not need to do any additional configuration. If you're using a supported web framework, the agent should work out of the box regardless of your Unicorn configuration.

If you are using a Ruby agent version prior to 3.8.0 with Unicorn, you will need to do one of the following in order to get data reporting:

Upgrade to newrelic_rpm 3.8.0 or higher
As noted above, versions 3.8.0 or higher of the newrelic_rpm gem should automatically work correctly regardless of your unicorn configuration.
Upload preload_app true
Use the preload_app true directive in your Unicorn configuration file. For more information, refer to the Unicorn documentation for this configuration setting. You must ensure that Unicorn sees your configuration file by specifying the -c <path> option to your unicorn invocation (Heroku users: This will be in your Procfile).

The directive is `preload_app true`, not `preload_app = true`. The form with the equals sign will fail silently.

Manually start the agent

If you do not want to use preload_app true, you can manually call the New Relic Ruby agent's handler for forking web servers from an initializer file in config/initializers`:

# Ensure the agent is started using Unicorn.
# This is needed when using Unicorn and preload_app is not set to true.
# See https://docs.newrelic.com/docs/ruby/no-data-with-unicorn 
if defined?(Unicorn) && File.basename($0).start_with?('unicorn') 
   ::NewRelic::Agent.manual_start() 
   ::NewRelic::Agent.after_fork(:force_reconnect => true) 
end

In order for your changes to take effect, do a "clean" restart (full stop and start). Doing a normal Unicorn restart with SIGUSR2 may not properly initialize the gem.

For more help

Additional documentation resources include:

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.