Class: ErrorReporting::ControllerReporter
- Inherits:
-
Object
- Object
- ErrorReporting::ControllerReporter
- Defined in:
- app/services/error_reporting.rb
Overview
Reporter that includes controller/request context
Always uses 'web' source (Rails backend)
Note: AppSignal already captures most request context automatically via:
- config.send_params = true (request params)
- config.send_session_data = true (session data)
- config.request_headers = [...] (headers including CF headers)
This reporter adds user/business context as tags for filtering in AppSignal UI.
Constant Summary collapse
- WARNING_EXCEPTIONS =
Exceptions that are expected behavior and should be reported as warnings
These go to web_warning namespace to reduce noise in critical error tracking [ 'CanCan::AccessDenied' # Authorization failures - expected when users lack permissions ].freeze
- INFO_EXCEPTIONS =
Exceptions that are informational (tracking only, no alerts)
These go to web_info namespace [ 'ActiveRecord::RecordNotFound', # Missing records - often bots/old links 'ActionController::RoutingError' # Bad URLs - bots probing ].freeze
Instance Method Summary collapse
- #critical(exception_or_message, context = {}) ⇒ Object
- #error(exception_or_message, context = {}) ⇒ Object
- #informational(message_or_exception, context = {}) ⇒ Object
-
#initialize(controller) ⇒ ControllerReporter
constructor
A new instance of ControllerReporter.
-
#report_exception(exception, context = {}) ⇒ Object
Smart exception reporting - automatically routes to correct severity/namespace based on exception type.
- #warning(message_or_exception, context = {}) ⇒ Object
Constructor Details
#initialize(controller) ⇒ ControllerReporter
Returns a new instance of ControllerReporter.
301 302 303 |
# File 'app/services/error_reporting.rb', line 301 def initialize(controller) @controller = controller end |
Instance Method Details
#critical(exception_or_message, context = {}) ⇒ Object
330 331 332 |
# File 'app/services/error_reporting.rb', line 330 def critical(, context = {}) ErrorReporting.critical(, build_context(context)) end |
#error(exception_or_message, context = {}) ⇒ Object
322 323 324 |
# File 'app/services/error_reporting.rb', line 322 def error(, context = {}) ErrorReporting.error(, build_context(context)) end |
#informational(message_or_exception, context = {}) ⇒ Object
334 335 336 |
# File 'app/services/error_reporting.rb', line 334 def informational(, context = {}) ErrorReporting.informational(, build_context(context)) end |
#report_exception(exception, context = {}) ⇒ Object
Smart exception reporting - automatically routes to correct severity/namespace
based on exception type. Use this when you want centralized severity decisions.
310 311 312 313 314 315 316 317 318 319 320 |
# File 'app/services/error_reporting.rb', line 310 def report_exception(exception, context = {}) exception_class = exception.class.name if WARNING_EXCEPTIONS.include?(exception_class) warning(exception, context.merge(reason: exception_class.demodulize.underscore)) elsif INFO_EXCEPTIONS.include?(exception_class) informational(exception, context.merge(reason: exception_class.demodulize.underscore)) else error(exception, context) end end |
#warning(message_or_exception, context = {}) ⇒ Object
326 327 328 |
# File 'app/services/error_reporting.rb', line 326 def warning(, context = {}) ErrorReporting.warning(, build_context(context)) end |