Last active
April 26, 2018 18:14
-
-
Save kindy/7312722 to your computer and use it in GitHub Desktop.
add X-Request-Start for New Relic
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
# 1. for: https://docs.newrelic.com/docs/features/request-queuing-and-tracking-front-end-time | |
# 2. as some guys ask this question for haproxy (seems can not do this): | |
# http://www.faultserver.com/q/answers-how-to-set-the-request-start-time-with-haproxy-447033.html | |
# 3. and, we can not add this header in httpd server, because it's too late.. | |
limit_req_zone $binary_remote_addr zone=one:1m rate=1r/s; | |
server { | |
listen 1025; | |
location = /a { | |
limit_req zone=one burst=2; | |
set_by_lua $now ' return ngx.now() '; | |
set $now2 ''; | |
access_by_lua ' ngx.var.now2 = ngx.now() '; | |
rewrite ^ /a-real break; | |
add_header X-Now "[ $now ]"; | |
add_header X-Now2 "[ $now2 ]"; | |
proxy_set_header X-Request-Start "[ $now ]"; | |
proxy_set_header X-Request-Start2 "[ $now2 ]"; | |
proxy_pass http://127.0.0.1:1025; | |
} | |
location = /a-real { | |
echo $http_x_request_start; | |
echo $http_x_request_start2; | |
echo done; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
URL from 2 is now: https://serverfault.com/questions/447033/how-to-set-the-request-start-time-with-haproxy