in lib/elastic_apm/middleware.rb [29:58]
def call(env)
begin
if running? && !path_ignored?(env)
transaction = start_transaction(env)
end
resp = @app.call env
rescue InternalError
raise
rescue ::Exception => e
context = ElasticAPM.build_context(rack_env: env, for_type: :error)
ElasticAPM.report(e, context: context, handled: false)
raise
ensure
if transaction
if resp
status, headers, _body = resp
transaction.add_response(status, headers: headers.dup)
transaction&.outcome = Transaction::Outcome.from_http_status(status)
else
transaction&.outcome = Transaction::Outcome::FAILURE
end
end
ElasticAPM.end_transaction http_result(status)
end
resp
end