Module: Errsight::Integrations::ActiveRecord
- Defined in:
- lib/errsight/integrations/active_record.rb
Overview
Subscribes to sql.active_record and pushes each non-cached, non-schema query into the current scope’s DB breadcrumb ring. When an exception is later captured in the same request/job, the event ships with the last 30 queries that ran — turning “ActiveRecord::RecordNotFound” from an opaque stack trace into “we ran these 5 queries before failing on this one.”
This is the killer demo for the Rails wedge. Sentry-ruby has SQL breadcrumbs but they come from a generic Notifications layer that treats every framework the same; here it’s first-class and tuned for what Rails apps actually emit.
Constant Summary collapse
- MAX_SQL_BYTES =
2_048- MAX_BIND_VALUES =
20- INTERNAL_NAMES =
%w[SCHEMA TRANSACTION].freeze
Class Method Summary collapse
-
.subscribe! ⇒ Object
Idempotent.
- .unsubscribe! ⇒ Object
Class Method Details
.subscribe! ⇒ Object
Idempotent. The subscriber handle is stored at module level so a double-require (gem reloaded in dev, or required from both the Railtie and a manual ‘require`) doesn’t double-fire crumbs.
25 26 27 28 29 30 |
# File 'lib/errsight/integrations/active_record.rb', line 25 def subscribe! return @subscriber if @subscriber @subscriber = ::ActiveSupport::Notifications.subscribe("sql.active_record") do |*args| handle(::ActiveSupport::Notifications::Event.new(*args)) end end |
.unsubscribe! ⇒ Object
32 33 34 35 36 37 |
# File 'lib/errsight/integrations/active_record.rb', line 32 def unsubscribe! if @subscriber ::ActiveSupport::Notifications.unsubscribe(@subscriber) @subscriber = nil end end |