Sha256: 3457ac8fa1d78b685acf3e528d16434616e1a91b5bdbd2e089214732ca97243b
Contents?: true
Size: 648 Bytes
Versions: 16
Compression:
Stored size: 648 Bytes
Contents
module Napa class Middleware class RequestStats def initialize(app) @app = app end def call(env) # Mark the request time start = Time.now # Process the request status, headers, body = @app.call(env) # Mark the response time stop = Time.now # Calculate total response time response_time = stop - start # Emit stats to StatsD Napa::Stats.emitter.increment('api_requests') Napa::Stats.emitter.timing('api_response_time', response_time) # Return the results [status, headers, body] end end end end
Version data entries
16 entries across 16 versions & 1 rubygems