Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

Commit

Permalink
Remove requirement for load ordering the gems with resque
Browse files Browse the repository at this point in the history
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
Bill Kayser committed Sep 7, 2011
1 parent 1bb3f0a commit 3c0dcc8
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 36 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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
Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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.
Expand All @@ -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

Expand Down
5 changes: 0 additions & 5 deletions lib/rpm_contrib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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."
end

require 'newrelic_rpm'
require 'rpm_contrib/instrumentation'
Expand All @@ -25,7 +21,6 @@ class Railtie < Rails::Railtie
end
# Rails 2.x
elsif defined?(Rails) && Rails.respond_to?(:configuration)

Rails.configuration.after_initialize { NewRelic::Control.instance.init_plugin }
else
raise "The rpm_contrib gem supports Rails 2.2+ only."
Expand Down
8 changes: 3 additions & 5 deletions lib/rpm_contrib/detection.rb
Original file line number Diff line number Diff line change
@@ -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
end
15 changes: 0 additions & 15 deletions lib/rpm_contrib/detection/resque.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/rpm_contrib/instrumentation/resque.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module NewRelicInstrumentation; end
end

::Resque.before_first_fork do
NewRelic::Agent.manual_start(:dispatcher => :resque)
NewRelic::Agent.manual_start(:dispatcher => :resque, :sync_startup => true)
end

::Resque.after_fork do
Expand Down
7 changes: 5 additions & 2 deletions test/test_curb.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
require "#{File.dirname(__FILE__)}/helper"
require 'curb'
begin
require 'curb'
rescue LoadError
end

class NewRelic::Agent::NetInstrumentationTest < Test::Unit::TestCase
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
Expand Down Expand Up @@ -63,4 +66,4 @@ def test_ignore
assert_equal 0, @engine.metrics.size
end

end
end if defined? ::Curl::Easy

0 comments on commit 3c0dcc8

Please sign in to comment.