Class: LcpRuby::Metrics::ErrorRecorder
- Inherits:
-
Object
- Object
- LcpRuby::Metrics::ErrorRecorder
- Defined in:
- lib/lcp_ruby/metrics/error_recorder.rb
Class Method Summary collapse
-
.record(error_class:, message:, stacktrace:, context: {}) ⇒ Object
Records an error to the error log table with rate limiting and atomic upsert.
Class Method Details
.record(error_class:, message:, stacktrace:, context: {}) ⇒ Object
Records an error to the error log table with rate limiting and atomic upsert.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/lcp_ruby/metrics/error_recorder.rb', line 11 def record(error_class:, message:, stacktrace:, context: {}) return unless error_log_active? fingerprint = Fingerprint.compute(error_class, .to_s, stacktrace || []) if RateLimiter.should_write?(fingerprint) pending = RateLimiter.drain_count(fingerprint) upsert(fingerprint, error_class, , stacktrace, context, pending) RateLimiter.mark_written(fingerprint) else RateLimiter.increment(fingerprint) end rescue StandardError => e raise if defined?(Rails) && Rails.env.local? Rails.logger.error("[LcpRuby::Metrics] ErrorRecorder failed: #{e.class}: #{e.}") if defined?(Rails) end |