lib/new_relic/agent/agent.rb in newrelic_rpm-2.12.1 vs lib/new_relic/agent/agent.rb in newrelic_rpm-2.12.2.beta
- old
+ new
@@ -352,11 +352,15 @@
# an application spawner. We detect the spawner and stop the agent so we don't
# report stats from a spawner. You don't want to do this check if you _know_
# you are not in a spawner (default is true).
def connect(options)
- return if @connected && !options[:force_reconnect]
+ # Don't proceed if we already connected (@connected=true) or if we tried
+ # to connect and were rejected with prejudice because of a license issue
+ # (@connected=false).
+ return if !@connected.nil? && !options[:force_reconnect]
+
keep_retrying = options[:keep_retrying].nil? || options[:keep_retrying]
check_for_spawner = options[:check_for_spawner].nil? || options[:check_for_spawner]
# wait a few seconds for the web server to boot, necessary in development
connect_retry_period = keep_retrying ? 10 : 0
@@ -552,11 +556,11 @@
# since otherwise it actually errors out.
dump_size = dump.size
# small payloads don't need compression
- return [dump, 'identity'] if dump_size < 2000
+ return [dump, 'identity'] if dump_size < (64*1024)
# medium payloads get fast compression, to save CPU
# big payloads get all the compression possible, to stay under
# the 2,000,000 byte post threshold
compression = dump_size < 2000000 ? Zlib::BEST_SPEED : Zlib::BEST_COMPRESSION
@@ -570,10 +574,10 @@
log.warn "Tried to send too much data: #{post_string.size} bytes"
raise PostTooBigException
end
def send_request(opts)
- request = Net::HTTP::Post.new(opts[:uri], 'CONTENT-ENCODING' => opts[:encoding], 'ACCEPT-ENCODING' => 'gzip', 'HOST' => opts[:collector].name)
+ request = Net::HTTP::Post.new(opts[:uri], 'CONTENT-ENCODING' => opts[:encoding], 'HOST' => opts[:collector].name)
request.content_type = "application/octet-stream"
request.body = opts[:data]
log.debug "Connect to #{opts[:collector]}#{opts[:uri]}"