lib/new_relic/agent/agent.rb in newrelic_rpm-3.14.1.311 vs lib/new_relic/agent/agent.rb in newrelic_rpm-3.14.2.312
- old
+ new
@@ -19,11 +19,11 @@
require 'new_relic/agent/commands/agent_command_router'
require 'new_relic/agent/event_listener'
require 'new_relic/agent/cross_app_monitor'
require 'new_relic/agent/synthetics_monitor'
require 'new_relic/agent/synthetics_event_buffer'
-require 'new_relic/agent/transaction_event_aggregator'
+require 'new_relic/agent/transaction_event_recorder'
require 'new_relic/agent/custom_event_aggregator'
require 'new_relic/agent/sampler_collection'
require 'new_relic/agent/javascript_instrumentor'
require 'new_relic/agent/vm/monotonic_gc_profiler'
require 'new_relic/agent/utilization_data'
@@ -62,11 +62,12 @@
@javascript_instrumentor = NewRelic::Agent::JavascriptInstrumentor.new(@events)
@harvester = NewRelic::Agent::Harvester.new(@events)
@after_fork_lock = Mutex.new
- @transaction_event_aggregator = NewRelic::Agent::TransactionEventAggregator.new(@events)
+ @transaction_event_recorder = NewRelic::Agent::TransactionEventRecorder.new
+
@custom_event_aggregator = NewRelic::Agent::CustomEventAggregator.new
@connect_state = :pending
@connect_attempts = 0
@environment_report = nil
@@ -136,13 +137,21 @@
# Responsbile for restarting the harvest thread
attr_reader :harvester
# GC::Profiler.total_time is not monotonic so we wrap it.
attr_reader :monotonic_gc_profiler
attr_reader :custom_event_aggregator
-
+ attr_reader :transaction_event_recorder
attr_reader :attribute_filter
+ def transaction_event_aggregator
+ @transaction_event_recorder.transaction_event_aggregator
+ end
+
+ def synthetics_event_aggregator
+ @transaction_event_recorder.synthetics_event_aggregator
+ end
+
# This method should be called in a forked process after a fork.
# It assumes the parent process initialized the agent, but does
# not assume the agent started.
#
# The call is idempotent, but not re-entrant.
@@ -555,11 +564,11 @@
# Clear out the metric data, errors, and transaction traces, etc.
def drop_buffered_data
@stats_engine.reset!
@error_collector.drop_buffered_data
@transaction_sampler.reset!
- @transaction_event_aggregator.reset!
+ @transaction_event_recorder.drop_buffered_data
@custom_event_aggregator.reset!
@sql_sampler.reset!
end
# Deprecated, and not part of the public API, but here for backwards
@@ -924,19 +933,24 @@
case endpoint
when :metric_data then @stats_engine
when :transaction_sample_data then @transaction_sampler
when :error_data then @error_collector.error_trace_aggregator
when :error_event_data then @error_collector.error_event_aggregator
- when :analytic_event_data then @transaction_event_aggregator
+ when :analytic_event_data then transaction_event_aggregator
when :custom_event_data then @custom_event_aggregator
when :sql_trace_data then @sql_sampler
end
end
def merge_data_for_endpoint(endpoint, data)
if data && !data.empty?
- container_for_endpoint(endpoint).merge!(data)
+ container = container_for_endpoint endpoint
+ if container.respond_to?(:has_metadata?) && container.has_metadata?
+ container_for_endpoint(endpoint).merge!(data, false)
+ else
+ container_for_endpoint(endpoint).merge!(data)
+ end
end
rescue => e
NewRelic::Agent.logger.error("Error while merging #{endpoint} data from child: ", e)
end
@@ -1098,10 +1112,11 @@
def harvest_and_send_errors
harvest_and_send_from_container(@error_collector.error_trace_aggregator, :error_data)
end
def harvest_and_send_analytic_event_data
- harvest_and_send_from_container(@transaction_event_aggregator, :analytic_event_data)
+ harvest_and_send_from_container(transaction_event_aggregator, :analytic_event_data)
+ harvest_and_send_from_container(synthetics_event_aggregator, :analytic_event_data)
harvest_and_send_from_container(@custom_event_aggregator, :custom_event_data)
end
def harvest_and_send_error_event_data
harvest_and_send_from_container @error_collector.error_event_aggregator, :error_event_data