• EnglishEspañol日本語한국어Português
  • Log inStart now

Incorrect counts with Unicorn


You're using New Relic Ruby APM and Unicorn together, but the counts for metrics and custom events seem too small.


Have Unicorn manually call NewRelic::Agent.shutdown to run the agent's exit handlers. Some of Unicorn's exit methods prevent the agent from shutting down as expected. The change below runs New Relic's shutdown method before killing the Unicorn process.

This fix relies on @expectedbehavior's fork of the unicorn-worker-killer gem.

  1. Add this to your Gemfile using:

    gem 'unicorn-worker-killer', git: 'https://github.com/expectedbehavior/unicorn-worker-killer'

    If you're already using unicorn-worker-killer in your Gemfile, update the reference to use this fork.

  2. Bundle:

    bundle install
  3. Update your unicorn configuration to include:

    require "unicorn/worker_killer"
    ::Unicorn::WorkerKiller.configure do |config|
    config.before_kill do |signal|
  4. Restart your server

Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.