Skip to content

Instantly share code, notes, and snippets.

@kindy
Last active April 26, 2018 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kindy/7312722 to your computer and use it in GitHub Desktop.
Save kindy/7312722 to your computer and use it in GitHub Desktop.
add X-Request-Start for New Relic
# 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;
}
}
@Firefishy
Copy link

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