Created
November 17, 2011 17:44
-
-
Save indirect/1373864 to your computer and use it in GitHub Desktop.
Rack middleware so NewRelic shows time as ruby
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
# This adds a request header so NewRelic knows when the middleware stack | |
# started processing. Hopefully this means we'll get better metrics, split | |
# between actual request queueing and time spent in the middlewares. | |
module Plex | |
class MiddlewareStart | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
env["HTTP_X_MIDDLEWARE_START"] = "t=#{(Time.now.to_f * 1000000).to_i}" | |
@app.call(env) | |
end | |
end | |
end | |
Rails.application.middleware.insert(0, Plex::MiddlewareStart) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment