Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Remove requirement for load ordering the gems with resque

RUBY-668 You should be able to specify the contrib gem/agent gem/resque gem in any order in a Gemfile and it should still work. Setting NEWRELIC_DISPATCHER should never be necessary for resque apps.
  • Loading branch information...
commit 3c0dcc82d7781afaf17fc2ccda68be6635280b74 1 parent 1bb3f0a
@bkayser bkayser authored
@@ -1,3 +1,9 @@
+* Version 2.1.5
+ Changed the resque detection so it does not depend on the load
+ order of resque => rpm_contrib => newrelic_rpm. The gems can be
+ installed in any order.
* Version 2.1.4
Updated requirements to latest agent with some bug fixes for background jobs
@@ -12,10 +12,6 @@ For Rails 3.0 and when using Bundler, add these dependencies to your Gemfile:
gem 'rpm_contrib'
gem 'newrelic_rpm'
-For some frameworks, it's important that the contrib gem is loaded
-before the newrelic_rpm gem. We hope to remove that unfortunate
-requirement in the future.
For Rails 2.1 and later, add these dependencies to your in your environment.rb:
config.gem 'rpm_contrib'
@@ -39,8 +35,10 @@ after all other frameworks have loaded:
### Troubleshooting Startup
If you've set up your gems to load as described above and you are still not seeing
-data in RPM, try setting the environment variable `NEWRELIC_DISPATCHER` to the name
-of your app server (Camping, Resque, Rake, etc).
+data in RPM, there may be a bug in detecting your framework. Try setting the
+environment variable `NEWRELIC_DISPATCHER` to the name of your app server (Camping,
+Resque, Rake, etc), and please report to us if this fixes the problem so we can
+fix the auto-detection logic.
If this does not help then set the `log_level` to `debug` in the `newrelic.yml` file
and examine the `newrelic_agent.log` file for errors after restarting your app.
@@ -65,8 +63,11 @@ You can disable it with `disable_cassandra_instrumentation` in your newrelic.yml
### Camping
The gem will detect a Camping app but you need to manually add the
-instrumentation to your configuration file. See RPMContrib::Instrumentation::Camping
-for more information.
+instrumentation to your configuration file. See
+RPMContrib::Instrumentation::Camping for more information.
+In addition you will need to load the gems in the following order: 1) Camping, 2) rpm_contrib,
+3) newrelic_rpm.
### Crack
5 lib/rpm_contrib.rb
@@ -2,11 +2,7 @@
module RPMContrib; end
-# Perform any framework/dispatcher detection before loading the rpm gem.
require 'rpm_contrib/detection'
-if defined?(::NewRelic) && defined?(::NewRelic::Control)
- puts "Warning! The rpm_contrib gem should be loaded before the newrelic_rpm gem if you are using Resque or Camping."
require 'newrelic_rpm'
require 'rpm_contrib/instrumentation'
@@ -25,7 +21,6 @@ class Railtie < Rails::Railtie
# Rails 2.x
elsif defined?(Rails) && Rails.respond_to?(:configuration)
Rails.configuration.after_initialize { NewRelic::Control.instance.init_plugin }
raise "The rpm_contrib gem supports Rails 2.2+ only."
8 lib/rpm_contrib/detection.rb
@@ -1,7 +1,5 @@
+# Currently the only framework we are detecting with an agent
+# patch is camping. You need to specify the camping gem prior
+# to the contrib gem and newrelic agent gem in order for this to work.
require 'rpm_contrib/detection/camping'
-require 'rpm_contrib/detection/resque'
-module RpmContrib
- module Detection
- end
15 lib/rpm_contrib/detection/resque.rb
@@ -1,15 +0,0 @@
-# Detect when running under camping and set the framework and dispatcher.
-module NewRelic
- class LocalEnvironment
- module Resque
- def discover_dispatcher
- super
- if defined?(::Resque::Worker) && @dispatcher.nil?
- @dispatcher = 'resque'
- end
- end
- end
- end
2  lib/rpm_contrib/instrumentation/resque.rb
@@ -54,7 +54,7 @@ module NewRelicInstrumentation; end
::Resque.before_first_fork do
- NewRelic::Agent.manual_start(:dispatcher => :resque)
+ NewRelic::Agent.manual_start(:dispatcher => :resque, :sync_startup => true)
::Resque.after_fork do
7 test/test_curb.rb
@@ -1,5 +1,8 @@
require "#{File.dirname(__FILE__)}/helper"
-require 'curb'
+require 'curb'
+rescue LoadError
class NewRelic::Agent::NetInstrumentationTest < Test::Unit::TestCase
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
@@ -63,4 +66,4 @@ def test_ignore
assert_equal 0, @engine.metrics.size
+end if defined? ::Curl::Easy

0 comments on commit 3c0dcc8

Please sign in to comment.
Something went wrong with that request. Please try again.