Class: Chronos::Agent
- Inherits:
-
Object
- Object
- Chronos::Agent
- Defined in:
- lib/chronos/agent.rb
Overview
Runtime composition root for the framework-independent Chronos agent.
Constant Summary collapse
- DEFAULT_FLUSH_TIMEOUT =
5.0
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #close(timeout = DEFAULT_FLUSH_TIMEOUT) ⇒ Object
- #diagnostics ⇒ Object
- #flush(timeout = DEFAULT_FLUSH_TIMEOUT) ⇒ Object
-
#initialize(config, options = {}) ⇒ Agent
constructor
A new instance of Agent.
- #notify(exception, context = {}) ⇒ Object
- #notify_sync(exception, context = {}) ⇒ Object
Constructor Details
#initialize(config, options = {}) ⇒ Agent
Returns a new instance of Agent.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/chronos/agent.rb', line 19 def initialize(config, = {}) @config = config @logger = [:logger] || Internal::SafeLogger.new(config.logger) @transport = [:transport] || Adapters::NetHttpTransport.new(config, @logger) unless Ports::Transport.compatible?(@transport) raise ArgumentError, "transport does not implement the Chronos transport port" end @queue = [:queue] || Internal::BoundedQueue.new(config.queue_size) @worker_pool = [:worker_pool] || Internal::WorkerPool.new(@queue, @transport, config.workers, @logger) @capture = [:capture] || Application::CaptureException.new(config, @worker_pool, @transport, @logger) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
17 18 19 |
# File 'lib/chronos/agent.rb', line 17 def config @config end |
Instance Method Details
#close(timeout = DEFAULT_FLUSH_TIMEOUT) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/chronos/agent.rb', line 46 def close(timeout = DEFAULT_FLUSH_TIMEOUT) @worker_pool.close(timeout) rescue StandardError => error @logger.warn("Chronos close failed: #{error.class}") false end |
#diagnostics ⇒ Object
53 54 55 |
# File 'lib/chronos/agent.rb', line 53 def diagnostics @queue.stats end |
#flush(timeout = DEFAULT_FLUSH_TIMEOUT) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/chronos/agent.rb', line 39 def flush(timeout = DEFAULT_FLUSH_TIMEOUT) @worker_pool.flush(timeout) rescue StandardError => error @logger.warn("Chronos flush failed: #{error.class}") false end |
#notify(exception, context = {}) ⇒ Object
31 32 33 |
# File 'lib/chronos/agent.rb', line 31 def notify(exception, context = {}) @capture.call(exception, context) end |
#notify_sync(exception, context = {}) ⇒ Object
35 36 37 |
# File 'lib/chronos/agent.rb', line 35 def notify_sync(exception, context = {}) @capture.call_sync(exception, context) end |