Class: Karafka::Web::Tracking::Ui::Errors
- Inherits:
-
Object
- Object
- Karafka::Web::Tracking::Ui::Errors
- Includes:
- Core::Helpers::Time, Helpers::ErrorInfo
- Defined in:
- lib/karafka/web/tracking/ui/errors.rb
Overview
Listener for tracking and reporting Web UI errors directly to Kafka
Unlike consumer and producer errors that are collected in samplers and dispatched periodically, UI errors need to be dispatched immediately and asynchronously from the web process (Puma/Rack) since there’s no background reporter running in the web UI.
Instance Method Summary collapse
-
#on_error_occurred(event) ⇒ Object
Tracks any UI related errors and dispatches them to Kafka.
Methods included from Helpers::ErrorInfo
#extract_error_info, #extract_error_message
Instance Method Details
#on_error_occurred(event) ⇒ Object
Tracks any UI related errors and dispatches them to Kafka
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/karafka/web/tracking/ui/errors.rb', line 25 def on_error_occurred(event) # Only process UI errors, ignore all other error types return unless event[:type] == 'web.ui.error' error_class, , backtrace = extract_error_info(event[:error]) error_data = { schema_version: SCHEMA_VERSION, id: SecureRandom.uuid, type: event[:type], error_class: error_class, error_message: , backtrace: backtrace, details: {}, occurred_at: float_now, process: { id: process_id } } # Validate the error data Tracking::Contracts::Error.new.validate!(error_data) # Dispatch error to Kafka asynchronously dispatch(error_data) rescue StandardError => e # If we fail to report an error, log it but don't raise to avoid error loops ::Karafka.logger.error("Failed to report UI error: #{e.}") end |