Sha256: 50553f1c5bb96d7bfa74c8dcd6e4500011175c0cfac395e613e24cf38fa33abd
Contents?: true
Size: 929 Bytes
Versions: 1
Compression:
Stored size: 929 Bytes
Contents
# frozen_string_literal: true module ElasticAPM # @api private class Middleware def initialize(app) @app = app end # rubocop:disable Metrics/MethodLength def call(env) begin transaction = ElasticAPM.transaction 'Rack', type_for(env), context: ElasticAPM.build_context(env) resp = @app.call env transaction.submit(resp[0], headers: resp[1]) if transaction rescue InternalError raise # Don't report ElasticAPM errors rescue ::Exception => e ElasticAPM.report(e, handled: false) transaction.submit(500) if transaction raise ensure transaction.release if transaction end resp end # rubocop:enable Metrics/MethodLength private def type_for(env) format( 'request.%s'.freeze, env.fetch('REQUEST_METHOD'.freeze, 'unknown'.freeze) ) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
elastic-apm-0.2.0 | lib/elastic_apm/middleware.rb |