Skip to content

Latest commit

 

History

History
46 lines (36 loc) · 1.47 KB

incorrect-data-unicorn.mdx

File metadata and controls

46 lines (36 loc) · 1.47 KB
title type tags metaDescription redirects freshnessValidatedDate
Incorrect counts with Unicorn
troubleshooting
Agents
Ruby agent
Troubleshooting
Troubleshooting for New Relic Ruby APM monitoring for use of Unicorn when metric and custom event metrics seem too low.
never

Problem

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

Solution

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.

  1. Bundle:
bundle install
  1. Update your unicorn configuration to include:
require "unicorn/worker_killer"

::Unicorn::WorkerKiller.configure do |config|
  config.before_kill do |signal|
    ::NewRelic::Agent.increment_metric("Custom/UnicornWorkerBeforeKillSignal/#{signal}")
    ::NewRelic::Agent.shutdown
  end
end
  1. Restart your server