module Sentry::Rails::Breadcrumb::ActiveSupportLogger

Public Class Methods

add(name, started, _finished, _unique_id, data) click to toggle source
# File lib/sentry/rails/breadcrumb/active_support_logger.rb, line 10
def add(name, started, _finished, _unique_id, data)
  # skip Rails' internal events
  return if name.start_with?("!")

  if data.is_a?(Hash)
    # we should only mutate the copy of the data
    data = data.dup
    cleanup_data(data)
  end

  crumb = Sentry::Breadcrumb.new(
    data: data,
    category: name,
    timestamp: started.to_i
  )
  Sentry.add_breadcrumb(crumb)
end
detach() click to toggle source
# File lib/sentry/rails/breadcrumb/active_support_logger.rb, line 37
def detach
  ::ActiveSupport::Notifications.unsubscribe(@subscriber)
end
inject() click to toggle source
# File lib/sentry/rails/breadcrumb/active_support_logger.rb, line 28
def inject
  @subscriber = ::ActiveSupport::Notifications.subscribe(/.*/) do |name, started, finished, unique_id, data|
    # we only record events that has a started timestamp
    if started.is_a?(Time)
      add(name, started, finished, unique_id, data)
    end
  end
end