Exception reporting / monitoring through external services.
- CLASS Hoodoo::Services::Middleware::ExceptionReporting::AirbrakeReporter
- CLASS Hoodoo::Services::Middleware::ExceptionReporting::BaseReporter
- CLASS Hoodoo::Services::Middleware::ExceptionReporting::Payload
- A
- C
- R
- W
Add an exception reporter class to the set of reporters. See the Hoodoo::Services::Middleware::ExceptionReporting::BaseReporter
class for an overview.
Whenever the middleware’s own exception handler catches an exception, it will run through the set of exception reporters (if any) and call each one to report exception details.
Reporters are maintained in a Set. Only one class will ever be stored and called once per exception; the original order of addition before duplicates is maintained (so if you add class A, then B, then A again, then class A is called first and only once, then B once).
Each reporter is called from its own Ruby Thread so that client API call response is kept fast. If a call fails, a debug log entry is made but processing of other reporters continues uninterrupted. It is up to individual reporter classes to manage thread safety.
klass
-
Hoodoo::Services::Middleware::ExceptionReporting::BaseReporter
subclass (class, not instance) to add.
Source: show
# File lib/hoodoo/services/middleware/exception_reporting/exception_reporting.rb, line 43 def self.add( klass ) unless klass < Hoodoo::Services::Middleware::ExceptionReporting::BaseReporter raise "Hoodoo::Services::Middleware.add must be called with a Hoodoo::Services::Middleware::ExceptionReporting::BaseReporter subclass" end @@reporter_pool.add( klass.instance ) end
Call all added exception reporters (see ::add
) to report an exception based on the context of an in-flight request/response cycle. Reporters need to support the contextual reporting mechanism. If any do not, the simpler ::report
mechanism is used as a fallback.
exception
-
Exception or Exception subclass instance to report.
context
-
Hoodoo::Services::Context
instance describing the in-flight request/response cycle.
Source: show
# File lib/hoodoo/services/middleware/exception_reporting/exception_reporting.rb, line 88 def self.contextual_report( exception, context ) payload = Payload.new( exception: exception, context: context ) @@reporter_pool.communicate( payload ) end
Remove an exception reporter class from the set of reporters. See ::add
for details.
klass
-
Hoodoo::Services::Middleware::ExceptionReporting::BaseReporter
subclass (class, not instance) to remove.
Source: show
# File lib/hoodoo/services/middleware/exception_reporting/exception_reporting.rb, line 57 def self.remove( klass ) unless klass < Hoodoo::Services::Middleware::ExceptionReporting::BaseReporter raise "Hoodoo::Services::Middleware.remove must be called with a Hoodoo::Services::Middleware::ExceptionReporting::BaseReporter subclass" end @@reporter_pool.remove( klass.instance ) end
Call all added exception reporters (see ::add
) to report an exception.
Source: show
# File lib/hoodoo/services/middleware/exception_reporting/exception_reporting.rb, line 73 def self.report( exception, rack_env = nil ) payload = Payload.new( exception: exception, rack_env: rack_env ) @@reporter_pool.communicate( payload ) end
Wait for all executing reporter threads to catch up before continuing.
timeout
-
Optional timeout wait delay for each thread. Default is 5 seconds.
Source: show
# File lib/hoodoo/services/middleware/exception_reporting/exception_reporting.rb, line 98 def self.wait( timeout = 5 ) @@reporter_pool.wait( per_instance_timeout: timeout ) end