Skip to content

Instantly share code, notes, and snippets.

View brettgoulder's full-sized avatar

Brett Goulder brettgoulder

  • Crunchy Data
  • San Francisco, CA
View GitHub Profile
@ryandotsmith
ryandotsmith / timer.rb
Last active December 15, 2015 00:19
Time rack requests and print heroku request id
class RackTimer
def initialize(app)
@app = app
end
def call(env)
start_request = Time.now
status, headers, body = @app.call(env)
elapsed = (Time.now - start_request) * 1000
$stdout.puts("request-id=#{env['HTTP_HEROKU_REQUEST_ID']} measure.rack-request=#{elapsed.round}ms")