lib/new_relic/agent/agent.rb in newrelic_rpm-3.7.2.195 vs lib/new_relic/agent/agent.rb in newrelic_rpm-3.7.3.199
- old
+ new
@@ -19,10 +19,11 @@
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/agent/javascript_instrumentor'
+require 'new_relic/agent/vm/monotonic_gc_profiler'
require 'new_relic/environment_report'
module NewRelic
module Agent
@@ -50,10 +51,11 @@
@transaction_rules = NewRelic::Agent::RulesEngine.new
@request_sampler = NewRelic::Agent::RequestSampler.new(@events)
@harvest_samplers = NewRelic::Agent::SamplerCollection.new(@events)
@javascript_instrumentor = NewRelic::Agent::JavascriptInstrumentor.new(@events)
@harvester = NewRelic::Agent::Harvester.new(@events)
+ @monotonic_gc_profiler = NewRelic::Agent::VM::MonotonicGCProfiler.new
@connect_state = :pending
@connect_attempts = 0
@environment_report = nil
@@ -103,10 +105,12 @@
# Transaction and metric renaming rules as provided by the
# collector on connect. The former are applied during txns,
# the latter during harvest.
attr_reader :transaction_rules
attr_reader :harvest_lock
+ # GC::Profiler.total_time is not monotonic so we wrap it.
+ attr_reader :monotonic_gc_profiler
# fakes out a transaction that did not happen in this process
# by creating apdex, summary metrics, and recording statistics
# for the transaction
#
@@ -834,26 +838,28 @@
end
end
end
include Connect
- # Accepts an array of (metrics, transaction_traces, errors) and merges
- # it into our current collection of data to send. Can be
- # dangerous if we re-merge the same data more than once - it
- # will be sent multiple times.
- def merge_data_from(data)
- metrics, transaction_traces, errors = data
- @stats_engine.merge!(metrics) if metrics
- if transaction_traces && transaction_traces.respond_to?(:any?) &&
- transaction_traces.any?
- @transaction_sampler.merge!(transaction_traces)
+ def container_for_endpoint(endpoint)
+ case endpoint
+ when :metric_data then @stats_engine
+ when :transaction_sample_data then @transaction_sampler
+ when :error_data then @error_collector
+ when :analytic_event_data then @request_sampler
+ when :sql_trace_data then @sql_sampler
end
- if errors && errors.respond_to?(:each)
- @error_collector.merge!(errors)
+ end
+
+ def merge_data_for_endpoint(endpoint, data)
+ if data && !data.empty?
+ container_for_endpoint(endpoint).merge!(data)
end
+ rescue => e
+ NewRelic::Agent.logger.error("Error while merging #{endpoint} data from child: ", e)
end
- public :merge_data_from
+ public :merge_data_for_endpoint
# Connect to the server and validate the license. If successful,
# connected? returns true when finished. If not successful, you can
# keep calling this. Return false if we could not establish a
# connection with the server and we should not retry, such as if