Sha256: 2cda23c3fc4765210a26c7aa32f077eb1ddcac0bbba6e7c7c68e4ddc2320f69d

Contents?: true

Size: 823 Bytes

Versions: 2

Compression:

Stored size: 823 Bytes

Contents

# frozen_string_literal: true

module PlainApm
  module Extensions
    module Exceptions
      class Rack
        include EventAttributes

        def initialize(app)
          @app = app
        end

        def call(env)
          response = @app.call(env)

          e = env["action_dispatch.exception"]
          report_exception(e, env) unless e.nil?

          response
        rescue Exception => e # standard:disable Lint/RescueException
          report_exception(e, env)
          raise
        end

        private

        def report_exception(e, env)
          name, event = attributes_from_exception(e, {env: env}, nil)

          return if event.nil?

          event[:source] = "rack_middleware"
          event[:name] = name

          PlainApm.agent.collect(event)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
plain_apm-0.10.2 lib/plain_apm/extensions/exceptions/rack.rb
plain_apm-0.10.0 lib/plain_apm/extensions/exceptions/rack.rb