Sha256: f4ef4c55451a24a882bf82b0e017698a63b18d155b5a43684d11a86801670ffd

Contents?: true

Size: 902 Bytes

Versions: 8

Compression:

Stored size: 902 Bytes

Contents

# frozen_string_literal: true

module PlainApm
  module Extensions
    module Exceptions
      class Rack
        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)
          event = {
            "source" => "rack_exceptions",
            "name" => "exception",
            "class" => e.class.name,
            "message" => e.message,
            "backtrace" => e.backtrace,
            "params" => env["action_dispatch.request.parameters"]
          }

          PlainApm::Agent.collect(event)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
plain_apm-0.5.3 lib/plain_apm/extensions/exceptions/rack.rb
plain_apm-0.5.2 lib/plain_apm/extensions/exceptions/rack.rb
plain_apm-0.5.1 lib/plain_apm/extensions/exceptions/rack.rb
plain_apm-0.5.0 lib/plain_apm/extensions/exceptions/rack.rb
plain_apm-0.4.0 lib/plain_apm/extensions/exceptions/rack.rb
plain_apm-0.3.0 lib/plain_apm/extensions/exceptions/rack.rb
plain_apm-0.2.9 lib/plain_apm/extensions/exceptions/rack.rb
plain_apm-0.2.8 lib/plain_apm/extensions/exceptions/rack.rb