lib/new_relic/agent/agent.rb in newrelic_rpm-5.2.0.345 vs lib/new_relic/agent/agent.rb in newrelic_rpm-5.3.0.346

- old
+ new

@@ -20,10 +20,11 @@ require 'new_relic/agent/cross_app_monitor' require 'new_relic/agent/distributed_trace_monitor' require 'new_relic/agent/synthetics_monitor' require 'new_relic/agent/transaction_event_recorder' require 'new_relic/agent/custom_event_aggregator' +require 'new_relic/agent/span_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' require 'new_relic/environment_report' @@ -59,19 +60,20 @@ @error_collector = NewRelic::Agent::ErrorCollector.new @transaction_rules = NewRelic::Agent::RulesEngine.new @harvest_samplers = NewRelic::Agent::SamplerCollection.new(@events) @monotonic_gc_profiler = NewRelic::Agent::VM::MonotonicGCProfiler.new @javascript_instrumentor = NewRelic::Agent::JavascriptInstrumentor.new(@events) - @adaptive_sampler = NewRelic::Agent::AdaptiveSampler.new + @adaptive_sampler = NewRelic::Agent::AdaptiveSampler.new(self.class.config[:sampling_target], + self.class.config[:sampling_target_period_in_seconds]) @harvester = NewRelic::Agent::Harvester.new(@events) @after_fork_lock = Mutex.new @transaction_event_recorder = NewRelic::Agent::TransactionEventRecorder.new + @custom_event_aggregator = NewRelic::Agent::CustomEventAggregator.new + @span_event_aggregator = NewRelic::Agent::SpanEventAggregator.new - @custom_event_aggregator = NewRelic::Agent::CustomEventAggregator.new - @connect_state = :pending @connect_attempts = 0 @environment_report = nil @waited_on_connect = nil @connected_pid = nil @@ -138,10 +140,11 @@ # 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 :span_event_aggregator attr_reader :transaction_event_recorder attr_reader :attribute_filter attr_reader :adaptive_sampler def transaction_event_aggregator @@ -544,10 +547,11 @@ @stats_engine.reset! @error_collector.drop_buffered_data @transaction_sampler.reset! @transaction_event_recorder.drop_buffered_data @custom_event_aggregator.reset! + @span_event_aggregator.reset! @sql_sampler.reset! if Agent.config[:clear_transaction_state_after_fork] TransactionState.tl_clear end @@ -1106,12 +1110,13 @@ 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(synthetics_event_aggregator, :analytic_event_data) - harvest_and_send_from_container(@custom_event_aggregator, :custom_event_data) + harvest_and_send_from_container(synthetics_event_aggregator, :analytic_event_data) + harvest_and_send_from_container(@custom_event_aggregator, :custom_event_data) + harvest_and_send_from_container(span_event_aggregator, :span_event_data) end def harvest_and_send_error_event_data harvest_and_send_from_container @error_collector.error_event_aggregator, :error_event_data end @@ -1134,9 +1139,13 @@ NewRelic::Agent.record_metric("Supportability/remote_unavailable/#{endpoint.to_s}", 0.0) end def transmit_event_data transmit_single_data_type(:harvest_and_send_analytic_event_data, "TransactionEvent") + end + + def transmit_span_event_data + transmit_single_data_type(:harvest_and_send_span_event_data, "SpanEvent") end def transmit_single_data_type(harvest_method, supportability_name) now = Time.now