Sha256: 2098ffed21eb89ad4fb4799d8509e6c13dc50e7a2752111f7f56cda2b3796c9b

Contents?: true

Size: 829 Bytes

Versions: 10

Compression:

Stored size: 829 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)
          source, event = attributes_from_exception(e, {env: env}, nil)

          return if event.nil?

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

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
plain_apm-0.9.2 lib/plain_apm/extensions/exceptions/rack.rb
plain_apm-0.9.1 lib/plain_apm/extensions/exceptions/rack.rb
plain_apm-0.9.0 lib/plain_apm/extensions/exceptions/rack.rb
plain_apm-0.8.8 lib/plain_apm/extensions/exceptions/rack.rb
plain_apm-0.8.7 lib/plain_apm/extensions/exceptions/rack.rb
plain_apm-0.8.6 lib/plain_apm/extensions/exceptions/rack.rb
plain_apm-0.8.5 lib/plain_apm/extensions/exceptions/rack.rb
plain_apm-0.8.4 lib/plain_apm/extensions/exceptions/rack.rb
plain_apm-0.8.3 lib/plain_apm/extensions/exceptions/rack.rb
plain_apm-0.8.2 lib/plain_apm/extensions/exceptions/rack.rb