Sha256: 577f059332bf45e488c9db473aec19b7e621cc0d2cb373e33b84bbefed3a4872

Contents?: true

Size: 770 Bytes

Versions: 1

Compression:

Stored size: 770 Bytes

Contents

# frozen_string_literal: true

module SpartanAPM
  module Middleware
    module Rack
      # Middleware that should be added of the end of the middleware chain.
      class EndMiddleware
        def initialize(app)
          @app = app
        end

        def call(env)
          start_time = Time.now
          SpartanAPM.capture(:app) do
            begin
              @app.call(env)
            ensure
              # Capture how much time was spent in middleware.
              middleware_start_time = env["spartan_apm.middleware_start_time"]
              if middleware_start_time
                SpartanAPM.capture_time(:middleware, start_time.to_f - middleware_start_time)
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spartan_apm-0.0.0.rc1 lib/spartan_apm/middleware/rack/end_middleware.rb