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 hidden or 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would you recommended an expanded version like: https://gist.github.com/chinshr/5314155
In either case, where exactly would I put it?