vendor/plugins/newrelic_rpm/lib/newrelic/agent/agent.rb
# Specifies the version of the agent's communication protocol
# with the NewRelic hosted site.
#
# VERSION HISTORY
# 1: Private Beta, Jan 10, 2008.  Serialized Marshalled Objects.  Unsupported after 5/29/2008.
# 2: Private Beta, March 15, 2008.  Compressed Serialzed Marshalled Objects (15-20x smaller)
# 3: June 19, 2008. Added transaction sampler capability with obfuscation
# 4: July 15, 2008. Added error capture
Specifies the version of the agent's communication protocol
with the NewRelic hosted site.

VERSION HISTORY
1: Private Beta, Jan 10, 2008.  Serialized Marshalled Objects.
Specifies the version of the agent ' s communication protocol with the NewRelic hosted site . VERSION HISTORY 1 : Private Beta Jan 10 2008 . Serialized Marshalled Objects .
def connect
      @connect_retry_period ||= 5
      @connect_attempts ||= 0
      sleep @connect_retry_period.to_i
      @agent_id = invoke_remote :launch, @local_host,
               @identifier, determine_home_directory, $$, @launch_time.to_f, NewRelic::VERSION::STRING, gather_info
      log! "Connected to NewRelic Service at #{@remote_host}:#{@remote_port}."
      log.debug "Agent ID = #{@agent_id}."
      @should_send_samples = invoke_remote :should_collect_samples, @agent_id
      @should_send_errors = invoke_remote :should_collect_errors, @agent_id
      log! "Transaction traces will be sent to the RPM service" if @use_transaction_sampler && @should_send_samples
      @connected = true
      @last_harvest_time = Time.now
      return true
    rescue LicenseException => e
      log! e.message, :error
      log! "Visit NewRelic.com to obtain a valid license key, or to upgrade your account."
      log! "Turning New Relic Agent off."
      @invalid_license = true
      return false
    rescue Timeout::Error, StandardError => e
      log.error "Error attempting to connect to New Relic RPM Service at #{@remote_host}:#{@remote_port}"
      log.error e.message
      log.debug e.backtrace.join("\n")
      @connect_attempts += 1
      if @connect_attempts > 20
        @connect_retry_period, period_msg = 10.minutes, "10 minutes"
      elsif @connect_attempts > 10
        @connect_retry_period, period_msg = 1.minutes, "1 minute"
      elsif @connect_attempts > 5
        @connect_retry_period, period_msg = 30, nil
      else
        @connect_retry_period, period_msg = 5, nil
      end
      log.info "Will re-attempt in #{period_msg}" if period_msg
      return true
    end
def connect @connect_retry_period ||= 5 @connect_attempts ||= 0 sleep @connect_retry_period . to_i @agent_id = invoke_remote :launch , @local_host , @identifier , determine_home_directory , $$ , @launch_time . to_f , NewRelic :: VERSION :: STRING , gather_info log! "Connected to NewRelic Service at #{@remote_host}:#{@remote_port}." log . debug "Agent ID = #{@agent_id}." @should_send_samples = invoke_remote :should_collect_samples , @agent_id @should_send_errors = invoke_remote :should_collect_errors , @agent_id log! "Transaction traces will be sent to the RPM service" if @use_transaction_sampler && @should_send_samples @connected = true @last_harvest_time = Time . now return true rescue LicenseException => e log! e . message , :error log! "Visit NewRelic.com to obtain a valid license key, or to upgrade your account." log! "Turning New Relic Agent off." @invalid_license = true return false rescue Timeout :: Error , StandardError => e log . error "Error attempting to connect to New Relic RPM Service at #{@remote_host}:#{@remote_port}" log . error e . message log . debug e . backtrace . join ( "\n" ) @connect_attempts += 1 if @connect_attempts > 20 @connect_retry_period , period_msg = 10 . minutes , "10 minutes" elsif @connect_attempts > 10 @connect_retry_period , period_msg = 1 . minutes , "1 minute" elsif @connect_attempts > 5 @connect_retry_period , period_msg = 30 , nil else @connect_retry_period , period_msg = 5 , nil end log . info "Will re-attempt in #{period_msg}" if period_msg return true end
Specifies the version of the agent's communication protocol
with the NewRelic hosted site.
Specifies the version of the agent ' s communication protocol with the NewRelic hosted site .
# wait a few seconds for the web server to boot # Ask the server for permission to send transaction samples.  determined by subscription license. # Ask for mermission to collect error data # retry logic