Class: Chronos::Application::CaptureException

Inherits:
Object
  • Object
show all
Defined in:
lib/chronos/application/capture_exception.rb

Overview

Orchestrates exception normalization, serialization, queueing, and delivery.

Examples:

capture.call(exception, :user => {"id" => "42"})

Instance Method Summary collapse

Constructor Details

#initialize(config, worker_pool, transport, logger = nil, options = {}) ⇒ CaptureException

Returns a new instance of CaptureException.



16
17
18
19
20
21
22
23
# File 'lib/chronos/application/capture_exception.rb', line 16

def initialize(config, worker_pool, transport, logger = nil, options = {})
  @config = config
  @worker_pool = worker_pool
  @transport = transport
  @logger = logger || Internal::SafeLogger.new(config.logger)
  @notice_builder = options[:notice_builder] || Core::NoticeBuilder.new(config)
  @serializer = options[:serializer] || Core::PayloadSerializer.new(config)
end

Instance Method Details

#call(exception, context = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/chronos/application/capture_exception.rb', line 25

def call(exception, context = {})
  return false unless capture_enabled?

  event = build_event(exception, context)
  @worker_pool.enqueue(event)
rescue StandardError => error
  diagnose(error)
  false
end

#call_sync(exception, context = {}) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/chronos/application/capture_exception.rb', line 35

def call_sync(exception, context = {})
  return false unless capture_enabled?

  event = build_event(exception, context)
  @transport.send_event(event).success?
rescue StandardError => error
  diagnose(error)
  false
end