Class: Hoodoo::Services::Middleware::ExceptionReporting::AirbrakeReporter
- Inherits:
-
BaseReporter
- Object
- Communicators::Slow
- BaseReporter
- Hoodoo::Services::Middleware::ExceptionReporting::AirbrakeReporter
- Defined in:
- lib/hoodoo/services/middleware/exception_reporting/reporters/airbrake_reporter.rb
Overview
Hoodoo::Services::Middleware::ExceptionReporting::BaseReporter subclass giving Hoodoo::Services::Middleware::ExceptionReporting access to Airbrake for error reporting. See airbrake.io.
Your application must include the Airbrake gem ‘airbrake’ via Gemfile (+gem ‘airbrake’+ / bundle install) or direct installation (gem install airbrake+).
The API key must be set during your application initialization and the class must be added to Hoodoo for use as an error reporter, e.g. through a ‘config/initializers’ folder, as follows:
require 'airbrake'
Airbrake.configure do | config |
config.project_key = 'YOUR_AIRBRAKE_PROJECT_KEY'
config.project_id = 'YOUR_AIRBRAKE_PROJECT_ID'
end
Hoodoo::Services::Middleware::ExceptionReporting.add(
Hoodoo::Services::Middleware::ExceptionReporting::AirbrakeReporter
) unless Service.config.env.test? || Service.config.env.development?
Services and the Hoodoo middleware do not pass Rails-like params around in forms or query strings, but do beware of search or filter query data containing sensitive material or POST bodies in e.g. JSON encoding containing sensitive data. This comes down to the filtering ability of the Airbrake gem:
https://github.com/airbrake/airbrake/wiki/Customizing-your-airbrake.rb
Instance Method Summary collapse
-
#contextual_report(e, context) ⇒ Object
Report an exception for errors that occur within a fully handled Rack request context, with a high level processed Hoodoo representation available.
-
#report(e, env) ⇒ Object
Report an exception to Airbrake.
Methods inherited from BaseReporter
Methods inherited from Communicators::Slow
Instance Method Details
#contextual_report(e, context) ⇒ Object
Report an exception for errors that occur within a fully handled Rack request context, with a high level processed Hoodoo representation available.
e
-
Exception (or subclass) instance to be reported.
context
-
Hoodoo::Services::Context instance describing an in-flight request/response cycle.
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/hoodoo/services/middleware/exception_reporting/reporters/airbrake_reporter.rb', line 73 def contextual_report( e, context ) opts = { :rack_env => context.owning_interaction.rack_request.env, :backtrace => Kernel.caller(), :environment_name => Hoodoo::Services::Middleware.environment, :session => user_data_for( context ) || 'unknown' } send_synchronously_to_airbrake( e, opts ) end |
#report(e, env) ⇒ Object
Report an exception to Airbrake.
e
-
Exception (or subclass) instance to be reported.
env
-
Optional Rack environment hash for the inbound request, for exception reports made in the context of Rack request handling. In the case of Airbrake, the call may just hang unless a Rack environment is provided.
57 58 59 60 61 62 |
# File 'lib/hoodoo/services/middleware/exception_reporting/reporters/airbrake_reporter.rb', line 57 def report( e, env ) opts = { :backtrace => Kernel.caller() } opts[ :rack_env ] = env unless env.nil? send_synchronously_to_airbrake( e, opts ) end |