lib/instrumental/agent.rb in instrumental_agent-1.0.1 vs lib/instrumental/agent.rb in instrumental_agent-2.0.0.alpha

- old
+ new

@@ -3,10 +3,11 @@ require 'logger' require 'openssl' rescue nil require 'resolv' require 'thread' require 'socket' +require 'metrician' module Instrumental class Agent BACKOFF = 2.0 @@ -75,14 +76,19 @@ @pid = Process.pid @allow_reconnect = true @certs = certificates @dns_resolutions = 0 @last_connect_at = 0 + @metrician = options[:metrician].nil? ? true : !!options[:metrician] @start_worker_mutex = Mutex.new @queue = Queue.new setup_cleanup_at_exit if @enabled + + if @metrician + Metrician.activate(self) + end end # Store a gauge for a metric, optionally at a specific time. # # agent.gauge('load', 1.23) @@ -471,9 +477,10 @@ when Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::EADDRINUSE, Timeout::Error # If the connection has been refused by Instrumental # or we cannot reach the server # or the connection state of this socket is in a race logger.error "unable to connect to Instrumental, hanging up with #{@queue.size} messages remaining" + logger.debug "Exception: #{err.inspect}\n#{err.backtrace.join("\n")}" allow_reconnect = false else report_exception(err) end if allow_reconnect == false ||