lib/new_relic/agent/agent.rb in newrelic_rpm-8.5.0 vs lib/new_relic/agent/agent.rb in newrelic_rpm-8.6.0

- old
+ new

@@ -23,10 +23,11 @@ require 'new_relic/agent/distributed_tracing' require 'new_relic/agent/monitors' 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/log_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' @@ -71,10 +72,11 @@ @after_fork_lock = Mutex.new @transaction_event_recorder = TransactionEventRecorder.new @events @custom_event_aggregator = CustomEventAggregator.new @events @span_event_aggregator = SpanEventAggregator.new @events + @log_event_aggregator = LogEventAggregator.new @events @connect_state = :pending @connect_attempts = 0 @waited_on_connect = nil @connected_pid = nil @@ -144,10 +146,11 @@ 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 :log_event_aggregator attr_reader :transaction_event_recorder attr_reader :attribute_filter attr_reader :adaptive_sampler attr_reader :environment_report @@ -557,10 +560,11 @@ @error_collector.drop_buffered_data @transaction_sampler.reset! @transaction_event_recorder.drop_buffered_data @custom_event_aggregator.reset! @span_event_aggregator.reset! + @log_event_aggregator.reset! @sql_sampler.reset! if Agent.config[:clear_transaction_state_after_fork] Tracer.clear_state end @@ -578,10 +582,11 @@ transmit_data transmit_analytic_event_data transmit_custom_event_data transmit_error_event_data transmit_span_event_data + transmit_log_event_data end end private @@ -605,10 +610,11 @@ ANALYTIC_EVENT_DATA = "analytic_event_data".freeze CUSTOM_EVENT_DATA = "custom_event_data".freeze ERROR_EVENT_DATA = "error_event_data".freeze SPAN_EVENT_DATA = "span_event_data".freeze + LOG_EVENT_DATA = "log_event_data".freeze def create_and_run_event_loop data_harvest = :"#{Agent.config[:data_report_period]}_second_harvest" event_harvest = :"#{Agent.config[:event_report_period]}_second_harvest" @@ -627,10 +633,13 @@ transmit_error_event_data end @event_loop.on(interval_for SPAN_EVENT_DATA) do transmit_span_event_data end + @event_loop.on(interval_for LOG_EVENT_DATA) do + transmit_log_event_data + end @event_loop.on(:reset_log_once_keys) do ::NewRelic::Agent.logger.clear_already_logged end @event_loop.fire_every(Agent.config[:data_report_period], data_harvest) @event_loop.fire_every(Agent.config[:event_report_period], event_harvest) @@ -891,10 +900,11 @@ when :error_event_data then @error_collector.error_event_aggregator when :analytic_event_data then transaction_event_aggregator when :custom_event_data then @custom_event_aggregator when :span_event_data then span_event_aggregator when :sql_trace_data then @sql_sampler + when :log_event_data then @log_event_aggregator end end def merge_data_for_endpoint(endpoint, data) if data && !data.empty? @@ -1078,10 +1088,14 @@ def harvest_and_send_span_event_data harvest_and_send_from_container(span_event_aggregator, :span_event_data) end + def harvest_and_send_log_event_data + harvest_and_send_from_container(@log_event_aggregator, :log_event_data) + end + def check_for_and_handle_agent_commands begin @agent_command_router.check_for_and_handle_agent_commands rescue ForceRestartException, ForceDisconnectException raise @@ -1118,10 +1132,15 @@ SPAN_EVENT = "SpanEvent".freeze def transmit_span_event_data transmit_single_data_type(:harvest_and_send_span_event_data, SPAN_EVENT) end + LOG_EVENT = "LogEvent".freeze + def transmit_log_event_data + transmit_single_data_type(:harvest_and_send_log_event_data, LOG_EVENT) + end + def transmit_single_data_type(harvest_method, supportability_name) now = Process.clock_gettime(Process::CLOCK_MONOTONIC) msg = "Sending #{supportability_name} data to New Relic Service" ::NewRelic::Agent.logger.debug msg @@ -1144,10 +1163,11 @@ harvest_and_send_error_event_data harvest_and_send_transaction_traces harvest_and_send_slowest_sql harvest_and_send_timeslice_data harvest_and_send_span_event_data + harvest_and_send_log_event_data check_for_and_handle_agent_commands harvest_and_send_for_agent_commands end ensure @@ -1172,9 +1192,10 @@ transmit_data transmit_analytic_event_data transmit_custom_event_data transmit_error_event_data transmit_span_event_data + transmit_log_event_data if @connected_pid == $$ && !@service.kind_of?(NewRelic::Agent::NewRelicService) ::NewRelic::Agent.logger.debug "Sending New Relic service agent run shutdown message" @service.shutdown else