Module: Sentry::Rails::Breadcrumb::ActiveSupportLogger

Defined in:
lib/sentry/rails/breadcrumb/active_support_logger.rb

Class Method Summary collapse

Class Method Details

.add(name, started, _finished, _unique_id, data) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/sentry/rails/breadcrumb/active_support_logger.rb', line 8

def add(name, started, _finished, _unique_id, data)
  # skip Rails' internal events
  return if name.start_with?("!")

  if data.is_a?(Hash)
    data = data.slice(*@allowed_keys[name])
  end

  crumb = Sentry::Breadcrumb.new(
    data: data,
    category: name,
    timestamp: started.to_i
  )
  Sentry.add_breadcrumb(crumb)
end

.detachObject



35
36
37
# File 'lib/sentry/rails/breadcrumb/active_support_logger.rb', line 35

def detach
  ::ActiveSupport::Notifications.unsubscribe(@subscriber)
end

.inject(allowed_keys) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/sentry/rails/breadcrumb/active_support_logger.rb', line 24

def inject(allowed_keys)
  @allowed_keys = allowed_keys

  @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