lib/new_relic/agent/agent.rb in newrelic_rpm-3.6.3.104 vs lib/new_relic/agent/agent.rb in newrelic_rpm-3.6.3.105.beta

- old
+ new

@@ -15,10 +15,11 @@ require 'new_relic/agent/database' require 'new_relic/agent/thread_profiler' require 'new_relic/agent/event_listener' require 'new_relic/agent/cross_app_monitor' require 'new_relic/agent/request_sampler' +require 'new_relic/agent/sampler_collection' require 'new_relic/environment_report' module NewRelic module Agent @@ -40,10 +41,11 @@ @cross_app_monitor = NewRelic::Agent::CrossAppMonitor.new(@events) @error_collector = NewRelic::Agent::ErrorCollector.new @transaction_rules = NewRelic::Agent::RulesEngine.new @metric_rules = NewRelic::Agent::RulesEngine.new @request_sampler = NewRelic::Agent::RequestSampler.new(@events) + @harvest_samplers = NewRelic::Agent::SamplerCollection.new(@events) @connect_state = :pending @connect_attempts = 0 @last_harvest_time = Time.now @@ -77,10 +79,11 @@ attr_reader :sql_sampler # begins a thread profile session when instructed by agent commands attr_reader :thread_profiler # error collector is a simple collection of recorded errors attr_reader :error_collector + attr_reader :harvest_samplers # whether we should record raw, obfuscated, or no sql attr_reader :record_sql # a configuration for the Real User Monitoring system - # handles things like static setup of the header for inclusion # into pages @@ -201,11 +204,10 @@ reset_stats # Don't ever check to see if this is a spawner. If we're in a forked process # I'm pretty sure we're not also forking new instances. start_worker_thread(options) - @stats_engine.start_sampler_thread end # True if we have initialized and completed 'start' def started? @started @@ -519,25 +521,11 @@ def reset_objects_with_locks @stats_engine = NewRelic::Agent::StatsEngine.new end def add_harvest_sampler(subclass) - begin - ::NewRelic::Agent.logger.debug "#{subclass.name} not supported on this platform." and return unless subclass.supported_on_this_platform? - sampler = subclass.new - if subclass.use_harvest_sampler? - stats_engine.add_harvest_sampler sampler - ::NewRelic::Agent.logger.debug "Registered #{subclass.name} for harvest time sampling" - else - stats_engine.add_sampler sampler - ::NewRelic::Agent.logger.debug "Registered #{subclass.name} for periodic sampling" - end - rescue NewRelic::Agent::Sampler::Unsupported => e - ::NewRelic::Agent.logger.info "#{subclass} sampler not available: #{e}" - rescue => e - ::NewRelic::Agent.logger.error "Error registering sampler:", e - end + @harvest_samplers.add_sampler(subclass) end private # All of this module used to be contained in the @@ -1052,9 +1040,10 @@ def transmit_data(disconnecting=false) now = Time.now ::NewRelic::Agent.logger.debug "Sending data to New Relic Service" + @events.notify(:before_harvest) @service.session do # use http keep-alive harvest_and_send_errors harvest_and_send_slowest_sample harvest_and_send_slowest_sql harvest_and_send_timeslice_data