Sha256: 731a61d7bcad4d7ecec7eb07658ed4313d5d9c393f093a85f2401ce6d1bfd86c

Contents?: true

Size: 1.24 KB

Versions: 47

Compression:

Stored size: 1.24 KB

Contents

require "sentry/rails/instrument_payload_cleanup_helper"

module Sentry
  module Rails
    module Breadcrumb
      module MonotonicActiveSupportLogger
        class << self
          include InstrumentPayloadCleanupHelper

          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

          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

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

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
sentry-rails-5.20.1 lib/sentry/rails/breadcrumb/monotonic_active_support_logger.rb
sentry-rails-5.20.0 lib/sentry/rails/breadcrumb/monotonic_active_support_logger.rb
sentry-rails-5.19.0 lib/sentry/rails/breadcrumb/monotonic_active_support_logger.rb
sentry-rails-5.18.2 lib/sentry/rails/breadcrumb/monotonic_active_support_logger.rb
sentry-rails-5.18.1 lib/sentry/rails/breadcrumb/monotonic_active_support_logger.rb
sentry-rails-5.18.0 lib/sentry/rails/breadcrumb/monotonic_active_support_logger.rb
sentry-rails-5.17.3 lib/sentry/rails/breadcrumb/monotonic_active_support_logger.rb
sentry-rails-5.17.2 lib/sentry/rails/breadcrumb/monotonic_active_support_logger.rb
sentry-rails-5.17.1 lib/sentry/rails/breadcrumb/monotonic_active_support_logger.rb
sentry-rails-5.17.0 lib/sentry/rails/breadcrumb/monotonic_active_support_logger.rb
sentry-rails-5.16.1 lib/sentry/rails/breadcrumb/monotonic_active_support_logger.rb
sentry-rails-5.15.2 lib/sentry/rails/breadcrumb/monotonic_active_support_logger.rb
sentry-rails-5.15.1 lib/sentry/rails/breadcrumb/monotonic_active_support_logger.rb
sentry-rails-5.15.0 lib/sentry/rails/breadcrumb/monotonic_active_support_logger.rb
sentry-rails-5.14.0 lib/sentry/rails/breadcrumb/monotonic_active_support_logger.rb
sentry-rails-5.13.0 lib/sentry/rails/breadcrumb/monotonic_active_support_logger.rb
sentry-rails-5.12.0 lib/sentry/rails/breadcrumb/monotonic_active_support_logger.rb
sentry-rails-5.11.0 lib/sentry/rails/breadcrumb/monotonic_active_support_logger.rb
sentry-rails-5.10.0 lib/sentry/rails/breadcrumb/monotonic_active_support_logger.rb
sentry-rails-5.9.0 lib/sentry/rails/breadcrumb/monotonic_active_support_logger.rb