Module: Sentry::Rails::Breadcrumb::MonotonicActiveSupportLogger

Extended by:
InstrumentPayloadCleanupHelper
Defined in:
lib/sentry/rails/breadcrumb/monotonic_active_support_logger.rb

Constant Summary

Constants included from InstrumentPayloadCleanupHelper

InstrumentPayloadCleanupHelper::IGNORED_DATA_TYPES

Class Method Summary collapse

Methods included from InstrumentPayloadCleanupHelper

cleanup_data

Class Method Details

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



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/sentry/rails/breadcrumb/monotonic_active_support_logger.rb', line 12

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

.detachObject



39
40
41
# File 'lib/sentry/rails/breadcrumb/monotonic_active_support_logger.rb', line 39

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

.injectObject



30
31
32
33
34
35
36
37
# File 'lib/sentry/rails/breadcrumb/monotonic_active_support_logger.rb', line 30

def inject
  @subscriber = ::ActiveSupport::Notifications.monotonic_subscribe(/.*/) do |name, started, finished, unique_id, data|
    # we only record events that has a float as started timestamp
    if started.is_a?(Float)
      add(name, started, finished, unique_id, data)
    end
  end
end