class ErrorEvent
Aggregated record of a failure observed across the system. Uses rising-edge capture so multiple call sites raising the same error produce a single event whose occurrence_count grows over time.
Constants
- SEVERITIES
- STATUSES
- SYSTEMS
Public Class Methods
# File app/models/error_event.rb, line 43 def record(catalog:, schema:, table: nil, operation:, source_system:, error_class: "StandardError", message:, severity: "error", context: {}, source_column: nil, status: "open") event = find_or_initialize_by( catalog_id: catalog&.id, schema: schema, table: table.to_s, operation: operation, source_system: source_system, message: message ) if event.persisted? # A failure that recurs after a resolution invalidates it: reopen the # event so it does not sit silently "resolved" while still broken. event.last_seen_at = Time.current event.occurrence_count += 1 event.context = event.context.merge(context.compact.transform_keys(&:to_s)) if event.resolved? event.status = "open" event.resolved_at = nil event.acknowledged_at = nil end event.save! else event.assign_attributes( error_class: error_class, severity: severity, status: status, context: context.compact.transform_keys(&:to_s), source_column: source_column, first_seen_at: Time.current, last_seen_at: Time.current, occurrence_count: 1 ) event.save! end event end
Records an error occurrence, incrementing a matching existing event or creating a new one. The first writer wins; later rescues do not overwrite. @param catalog [Catalog, nil] the catalog the failure relates to, if any @param schema [String] the namespace where the failure occurred @param table [String, nil] the table where the failure occurred @param operation [String] the operation that was being performed @param source_system [String] the subsystem that reported the failure @param error_class [String] the Ruby error class name @param message [String] the error message @param severity [String] one of the SEVERITIES @param context [Hash] extra structured context stored on the event @param source_column [String, nil] the column the failure relates to, if any @return [ErrorEvent] the created or updated event
Public Instance Methods
Source
# File app/models/error_event.rb, line 87 def resolved? = status == "resolved"
Whether the status is resolved. @return [Boolean]