Skip to content

Instantly share code, notes, and snippets.

@octplane
Last active December 17, 2015 17:09
Show Gist options
  • Save octplane/5643709 to your computer and use it in GitHub Desktop.
Save octplane/5643709 to your computer and use it in GitHub Desktop.
Initializer for rails if you use newrelic outside Heroku or without Mongrel. Will speed up all instrumented request by about 100%
module NewRelic
module Agent
module Instrumentation
# == NewRelic instrumentation for controller actions and tasks
#
# This instrumentation is applied to the action controller to collect
# metrics for every web request.
#
# It can also be used to capture performance information for
# background tasks and other non-web transactions, including
# detailed transaction traces and traced errors.
#
# For details on how to instrument background tasks see
# ClassMethods#add_transaction_tracer and
# #perform_action_with_newrelic_trace
#
module ControllerInstrumentation
# Do not loose time here. Fix newrelic ObjectSpace.each search at each request.
def _record_queue_length
return
end
end
end
end
end
@octplane
Copy link
Author

The culprit is https://github.com/newrelic/rpm/blob/master/lib/new_relic/agent/instrumentation/controller_instrumentation.rb#L475 that does a lazy assignment of a nil value when not using Mongrel.

LAZY+NIL = STILL LAZY.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment