lib/new_relic/agent/agent.rb in newrelic_rpm-3.11.2.286 vs lib/new_relic/agent/agent.rb in newrelic_rpm-3.12.0.288
- old
+ new
@@ -26,10 +26,11 @@
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'
+require 'new_relic/agent/attribute_filter'
module NewRelic
module Agent
# The Agent is a singleton that is instantiated when the plugin is
@@ -70,12 +71,26 @@
@connect_attempts = 0
@environment_report = nil
@harvest_lock = Mutex.new
@obfuscator = lambda {|sql| NewRelic::Agent::Database.default_sql_obfuscator(sql) }
+
+ setup_attribute_filter
end
+ def setup_attribute_filter
+ refresh_attribute_filter
+
+ @events.subscribe(:finished_configuring) do
+ refresh_attribute_filter
+ end
+ end
+
+ def refresh_attribute_filter
+ @attribute_filter = NewRelic::Agent::AttributeFilter.new(NewRelic::Agent.config)
+ end
+
# contains all the class-level methods for NewRelic::Agent::Agent
module ClassMethods
# Should only be called by NewRelic::Control - returns a
# memoized singleton instance of the agent, creating one if needed
def instance
@@ -122,10 +137,12 @@
attr_reader :harvest_lock
# GC::Profiler.total_time is not monotonic so we wrap it.
attr_reader :monotonic_gc_profiler
attr_reader :custom_event_aggregator
+ attr_reader :attribute_filter
+
# 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.
@@ -181,17 +198,14 @@
# True if we have initialized and completed 'start'
def started?
@started
end
- # Attempt a graceful shutdown of the agent, running the worker
- # loop if it exists and is running.
- #
- # Options:
- # :force_send => (true/false) # force the agent to send data
- def shutdown(options={})
- return if not started?
+ # Attempt a graceful shutdown of the agent, flushing any remaining
+ # data.
+ def shutdown
+ return unless started?
::NewRelic::Agent.logger.info "Starting Agent shutdown"
stop_event_loop
trap_signals_for_litespeed
untraced_graceful_disconnect
@@ -205,14 +219,11 @@
NewRelic::Agent.config.remove_config_type(:manual)
NewRelic::Agent.config.remove_config_type(:server)
end
def stop_event_loop
- if @event_loop
- @event_loop.run_once(true) if Agent.config[:force_send]
- @event_loop.stop
- end
+ @event_loop.stop if @event_loop
end
def trap_signals_for_litespeed
# if litespeed, then ignore all future SIGUSR1 - it's
# litespeed trying to shut us down
@@ -1054,10 +1065,10 @@
# This handles getting the transaction traces and then sending
# them across the wire. This includes gathering SQL
# explanations, stripping out stack traces, and normalizing
# SQL. note that we explain only the sql statements whose
- # segments' execution times exceed our threshold (to avoid
+ # nodes' execution times exceed our threshold (to avoid
# unnecessary overhead of running explains on fast queries.)
def harvest_and_send_transaction_traces
harvest_and_send_from_container(@transaction_sampler, :transaction_sample_data)
end