Class: NewRelic::Agent::Agent

Inherits:
Object
  • Object
show all
Extended by:
ClassMethods, Configuration::Instance
Includes:
InstanceMethods, BrowserMonitoring
Defined in:
lib/new_relic/agent/agent.rb

Overview

The Agent is a singleton that is instantiated when the plugin is activated. It collects performance data from ruby applications in realtime as the application runs, and periodically sends that data to the NewRelic server.

Direct Known Subclasses

ShimAgent

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Instance Attribute Summary

Attributes included from InstanceMethods

#agent_command_router, #beacon_configuration, #cross_app_encoding_bytes, #cross_app_monitor, #cross_process_id, #error_collector, #events, #harvest_lock, #harvest_samplers, #metric_rules, #obfuscator, #record_sql, #service, #sql_sampler, #stats_engine, #transaction_rules, #transaction_sampler

Attributes included from InstanceMethods::Connect

#connect_attempts

Instance Method Summary collapse

Methods included from Configuration::Instance

config, reset_config

Methods included from ClassMethods

instance

Methods included from BrowserMonitoring

browser_monitoring_transaction_name, #browser_timing_footer, #browser_timing_header, current_timings, current_transaction, obfuscate

Methods included from InstanceMethods

#add_harvest_sampler, #after_fork, #agent_should_start?, #defer_for_delayed_job?, #end_transaction, #merge_data_from, #pop_trace_execution_flag, #push_trace_execution_flag, #record_transaction, #reset_objects_with_locks, #reset_stats, #set_record_sql, #set_record_tt, #shutdown, #start, #start_transaction, #started?, #unsent_errors_size, #unsent_timeslice_data, #unsent_traces_size

Methods included from InstanceMethods::Connect

#add_rules_to_engine, #apdex_f, #connect_retry_period, #connect_settings, #connect_to_server, #connected?, #disconnect, #disconnected?, #environment_for_connect, #finish_setup, #generate_environment_report, #handle_license_error, #handle_unrecoverable_agent_error, #log_collector_messages, #log_connection!, #log_error, #note_connect_failure, #query_server_for_configuration, #should_connect?

Methods included from InstanceMethods::StartWorkerThread

#catch_errors, #create_and_run_worker_loop, #deferred_work!, #handle_force_disconnect, #handle_force_restart, #handle_other_error, #handle_server_connection_problem, #log_worker_loop_start, #reset_harvest_locks, #synchronize_with_harvest

Methods included from InstanceMethods::Start

#already_started?, #app_name_configured?, #check_config_and_start_agent, #connect_in_foreground, #correct_license_length, #defer_for_resque?, #disabled?, #has_correct_license_key?, #has_license_key?, #install_exit_handler, #log_app_name, #log_dispatcher, #log_environment, #log_startup, #log_version_and_pid, #monitoring?, #using_forking_dispatcher?, #using_sinatra?, #weird_ruby?

Constructor Details

#initializeAgent

Returns a new instance of Agent.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/new_relic/agent/agent.rb', line 34

def initialize
  # FIXME: temporary work around for RUBY-839
  # This should be handled with a configuration callback
  if Agent.config[:monitor_mode]
    @service = NewRelic::Agent::NewRelicService.new
  end

  @launch_time = Time.now

  @events                = NewRelic::Agent::EventListener.new
  @stats_engine          = NewRelic::Agent::StatsEngine.new
  @transaction_sampler   = NewRelic::Agent::TransactionSampler.new
  @sql_sampler           = NewRelic::Agent::SqlSampler.new
  @agent_command_router  = NewRelic::Agent::Commands::AgentCommandRouter.new(@events)
  @cross_app_monitor     = NewRelic::Agent::CrossAppMonitor.new(@events)
  @error_collector       = NewRelic::Agent::ErrorCollector.new
  @transaction_rules     = NewRelic::Agent::RulesEngine.new
  @metric_rules          = NewRelic::Agent::RulesEngine.new
  @request_sampler       = NewRelic::Agent::RequestSampler.new(@events)
  @harvest_samplers      = NewRelic::Agent::SamplerCollection.new(@events)

  @connect_state      = :pending
  @connect_attempts   = 0
  @environment_report = nil

  @last_harvest_time = Time.now
  @harvest_lock = Mutex.new
  @obfuscator = lambda {|sql| NewRelic::Agent::Database.default_sql_obfuscator(sql) }
end