Sha256: d01761e5032d2e3c8c63d7cea2c54731bef4d9533b9effc07896fc2eef2c3a50
Contents?: true
Size: 1.46 KB
Versions: 8
Compression:
Stored size: 1.46 KB
Contents
# frozen_string_literal: true module PlainApm module Extensions module Exceptions class Rack # FIXME: This is duplicated for ErrorReporter IGNORED_EXCEPTIONS = [ "Sidekiq::JobRetry::Skip", # Sidekiq uses exceptions for control flow. "ActionController::RoutingError" # Rails unmapped route, raised before the request hits the app. ].freeze 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) return if IGNORED_EXCEPTIONS.include?(e.class.name) event = { "source" => "rack_exceptions", "name" => "exception", "class" => e.class.name, "message" => e.message, "backtrace" => e.backtrace, "params" => env["action_dispatch.request.parameters"] } if e.cause event.merge!({ "cause_class" => e.cause.class.name, "cause_message" => e.cause.message, "cause_backtrace" => e.cause.backtrace }) end PlainApm::Agent.collect(event) end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems