14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/rails_informant/error_recorder.rb', line 14
def record(error, severity: "error", context: {}, source: nil, env: nil)
return unless RailsInformant.initialized?
return if self_caused_error?(error)
now = Time.current
attrs = ContextBuilder.group_attributes(error, severity:, context:, env:, now:)
fingerprint = Fingerprint.generate(error)
event = run_before_record_callbacks(error, attrs, env:, fingerprint:)
return if event.halted?
fingerprint = event.fingerprint
attrs[:severity] = event.severity if %w[error warning info].include?(event.severity)
group = ErrorGroup.find_or_create_for(fingerprint, attrs)
group.detect_regression!
return if spike_limit_exceeded?(group)
store_occurrence(group, error, env:, context:) if should_store_occurrence?(group)
notify(group)
rescue StandardError => e
Rails.logger.error "[RailsInformant] Capture failed: #{e.class}: #{e.message}\n#{e.backtrace&.first(5)&.join("\n")}"
end
|