Skip to content

Instantly share code, notes, and snippets.

@ryandotsmith
Last active December 15, 2015 00:19
Show Gist options
  • Select an option

  • Save ryandotsmith/5172179 to your computer and use it in GitHub Desktop.

Select an option

Save ryandotsmith/5172179 to your computer and use it in GitHub Desktop.
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")
[status, headers, body]
end
end
@dfuentes77
Copy link

Would you recommended an expanded version like: https://gist.github.com/chinshr/5314155

In either case, where exactly would I put it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment