diff --git a/CHANGELOG b/CHANGELOG index ad707c3..be5c3ff 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +* Version 1.0.2 + + Improved Camping support + * Version 1.0.1 Removed DelayedJob, put back in core agent diff --git a/lib/new_relic/control/camping.rb b/lib/new_relic/control/camping.rb new file mode 100644 index 0000000..cfd3269 --- /dev/null +++ b/lib/new_relic/control/camping.rb @@ -0,0 +1,12 @@ +require 'new_relic/control/ruby' +# This is the framework control object for Camping apps. +# It is loaded by virtue of detecting 'camping' as the framework +# in the rpm_contrib/detection/camping.rb file. It gets loaded +# by the new_relic/control.rb file. +class NewRelic::Control::Camping < NewRelic::Control::Ruby + def init_config(options) + super + @local_env.dispatcher = 'camping' + self['app_name'] ||= 'Camping Application' + end +end diff --git a/lib/rpm_contrib/detection/camping.rb b/lib/rpm_contrib/detection/camping.rb new file mode 100644 index 0000000..ca92da8 --- /dev/null +++ b/lib/rpm_contrib/detection/camping.rb @@ -0,0 +1,23 @@ +# Detect when running under camping and set the framework and dispatcher. + +module NewRelic + class LocalEnvironment + module Camping + def discover_framework + if defined?(::Camping) + puts "framework is camping" + @framework = 'camping' + else + super + end + end + def discover_dispatcher + super + if defined?(::Camping) && @dispatcher.nil? + @dispatcher = 'camping' + end + end + end + end +end + diff --git a/lib/rpm_contrib/instrumentation/camping.rb b/lib/rpm_contrib/instrumentation/camping.rb index 86b213d..2d1e7f8 100644 --- a/lib/rpm_contrib/instrumentation/camping.rb +++ b/lib/rpm_contrib/instrumentation/camping.rb @@ -4,39 +4,33 @@ module RPMContrib module Instrumentation # == Instrumentation for Camping # To instrument all controllers do the following: - # 1. Add the necessary NewRelic-specific requires in your require section + # 1. Add require 'rpm_contrib' after loading camping. # 2. Add an include at the end of your main Camping app module - # 3. Add a call to NewRelic::Agent.manual_start at the end of the file to start the agent - # 4. Run the following command to get the NewRelic license key to use: heroku config -all - # 5. Create a newrelic.yml under the /config folder with the following content: + # 3. Run the following command to get the NewRelic license key to use: heroku config -all + # 4. Create a newrelic.yml under the /config folder with the following content: # - # common: &default_settings - # license_key: 'PASTE THE VALUE OF NEW_RELIC_LICENSE_KEY HERE' - # agent_enabled: true - # app_name: PASTE THE NAME OF YOUR CAMPING APP HERE - # enabled: true + # common: &default_settings + # license_key: 'PASTE THE VALUE OF NEW_RELIC_LICENSE_KEY HERE' + # app_name: PASTE THE NAME OF YOUR CAMPING APP HERE + # monitor_mode: true # - # production: - # <<: *default_settings - # enabled: true + # production: + # <<: *default_settings + # + # Camping code example: + # ------------------------------------------------------------------------------------- # - # Camping code example: - # -------------------------------------------------------------------------------------- # require "newrelic_rpm" - # require 'new_relic/agent/agent' - # require 'new_relic/agent/instrumentation/controller_instrumentation' - # require 'new_relic/agent/instrumentation/camping' # # Camping.goes :NewRelicCampingTest # # module NewRelicCampingTest - # # your code + # # your code + # + # include NewRelic::Agent::Instrumentation::Camping # - # include NewRelic::Agent::Instrumentation::ControllerInstrumentation - # include NewRelic::Agent::Instrumentation::Camping # end # - # NewRelic::Agent.manual_start # module Camping @@ -49,23 +43,8 @@ def self.included(mod) # we need to evaluate "weld" the NewRelic plugin in the context of the new Base (Kernel.const_get(mod.name)::Base).module_eval do - - # Add the new method to the Camping app's Base module - # since the Camping::Base module is being included - # in every Camping controller - - def service_with_newrelic(*args) - perform_action_with_newrelic_trace(:category => :rack) do - service_without_newrelic(*args) - end - end - - # Alias the "standard" service method - # so we can provide a level of indirection - # to perform the tracing for NewRelic - - alias service_without_newrelic service - alias service service_with_newrelic + include NewRelic::Agent::Instrumentation::ControllerInstrumentation + add_transaction_tracer :service end end