If you do not see data with Unicorn, follow these procedures based on your New Relic Ruby agent version.
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.
- Use the
preload_app truedirective 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
unicorninvocation (Heroku users: This will be in your
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
# 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
SIGUSR2may not properly initialize the gem.