Sha256: b90fc4ab30bb9d1e8c7cf411f55f5bb5afcfee3d614278a315c16d86365c0af7

Contents?: true

Size: 675 Bytes

Versions: 4

Compression:

Stored size: 675 Bytes

Contents

# frozen_string_literal: true

module Trifle
  module Traces
    module Middleware
      class Rack
        def initialize(app)
          @app = app
        end

        def call(env)
          # TODO: set up key
          # Trifle::Traces.tracer = Trifle::Traces.default.tracer_class.new
          @status, @headers, @response = @app.call(env)
        rescue => e # rubocop:disable Style/RescueStandardError
          Trifle::Traces.tracer&.trace("Exception: #{e}", state: :error)
          Trifle::Traces.tracer&.fail!
          raise e
        ensure
          Trifle::Traces.tracer&.wrapup
          [@status, @headers, @response]
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
trifle-traces-1.1.2 lib/trifle/traces/middleware/rack.rb
trifle-traces-1.1.1 lib/trifle/traces/middleware/rack.rb
trifle-traces-1.1.0 lib/trifle/traces/middleware/rack.rb
trifle-traces-1.0.1 lib/trifle/traces/middleware/rack.rb