Last active
December 15, 2015 00:19
-
-
Save ryandotsmith/5172179 to your computer and use it in GitHub Desktop.
Time rack requests and print heroku request id
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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
maybe it's better to tap the result vs keeping the variables around?