Sha256: 0fb06afce1012fe1fcd596046d6d95a8f49f4b95f5109922756bc6c9687aba5f
Contents?: true
Size: 1.54 KB
Versions: 1
Compression:
Stored size: 1.54 KB
Contents
module Sentry module Rails class CaptureExceptions < Sentry::Rack::CaptureExceptions def initialize(app) super if defined?(::Sprockets::Rails) @assets_regex = %r(\A/{0,2}#{::Rails.application.config.assets.prefix}) end end private def collect_exception(env) return nil if env["sentry.already_captured"] super || env["action_dispatch.exception"] || env["sentry.rescued_exception"] end def transaction_op "rails.request".freeze end def capture_exception(exception, env) request = ActionDispatch::Request.new(env) # the exception will be swallowed by ShowExceptions middleware return if request.show_exceptions? && !Sentry.configuration.rails.report_rescued_exceptions Sentry::Rails.capture_exception(exception).tap do |event| env[ERROR_EVENT_ID_KEY] = event.event_id if event end end def start_transaction(env, scope) sentry_trace = env["HTTP_SENTRY_TRACE"] baggage = env["HTTP_BAGGAGE"] options = { name: scope.transaction_name, source: scope.transaction_source, op: transaction_op } if @assets_regex && scope.transaction_name.match?(@assets_regex) options.merge!(sampled: false) end transaction = Sentry::Transaction.from_sentry_trace(sentry_trace, baggage: baggage, **options) if sentry_trace Sentry.start_transaction(transaction: transaction, custom_sampling_context: { env: env }, **options) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sentry-rails-5.5.0 | lib/sentry/rails/capture_exceptions.rb |