Sha256: 2b699c80fb996c100378dc17c180a4b21cfd93dc2cd851a89162be5858bf4f52

Contents?: true

Size: 1.21 KB

Versions: 37

Compression:

Stored size: 1.21 KB

Contents

require "sentry/rails/instrument_payload_cleanup_helper"

module Sentry
  module Rails
    module Breadcrumb
      module ActiveSupportLogger
        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.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

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

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
sentry-rails-5.9.0 lib/sentry/rails/breadcrumb/active_support_logger.rb
sentry-rails-5.8.0 lib/sentry/rails/breadcrumb/active_support_logger.rb
sentry-rails-5.7.0 lib/sentry/rails/breadcrumb/active_support_logger.rb
sentry-rails-5.6.0 lib/sentry/rails/breadcrumb/active_support_logger.rb
sentry-rails-5.5.0 lib/sentry/rails/breadcrumb/active_support_logger.rb
sentry-rails-5.4.2 lib/sentry/rails/breadcrumb/active_support_logger.rb
sentry-rails-5.4.1 lib/sentry/rails/breadcrumb/active_support_logger.rb
sentry-rails-5.4.0 lib/sentry/rails/breadcrumb/active_support_logger.rb
sentry-rails-5.3.1 lib/sentry/rails/breadcrumb/active_support_logger.rb
sentry-rails-5.3.0 lib/sentry/rails/breadcrumb/active_support_logger.rb
sentry-rails-5.2.1 lib/sentry/rails/breadcrumb/active_support_logger.rb
sentry-rails-5.2.0 lib/sentry/rails/breadcrumb/active_support_logger.rb
sentry-rails-5.1.1 lib/sentry/rails/breadcrumb/active_support_logger.rb
sentry-rails-5.1.0 lib/sentry/rails/breadcrumb/active_support_logger.rb
sentry-rails-5.0.2 lib/sentry/rails/breadcrumb/active_support_logger.rb
sentry-rails-5.0.1 lib/sentry/rails/breadcrumb/active_support_logger.rb
sentry-rails-5.0.0 lib/sentry/rails/breadcrumb/active_support_logger.rb
sentry-rails-4.9.2 lib/sentry/rails/breadcrumb/active_support_logger.rb
sentry-rails-4.9.1 lib/sentry/rails/breadcrumb/active_support_logger.rb
sentry-rails-4.9.0 lib/sentry/rails/breadcrumb/active_support_logger.rb