Last active
February 2, 2017 10:44
-
-
Save felixbuenemann/bce1fc848da498ffec6d to your computer and use it in GitHub Desktop.
Varnish 4 X-Request-Start Header for New Relic Queue Time Reporting
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
# To allow inline-C in VCL start varnishd with -p vcc_allow_inline_c=on | |
C{ | |
#include <sys/time.h> | |
#include <stdio.h> | |
static const struct gethdr_s VGC_HDR_REQ_reqstart = { HDR_REQ, "\020X-Request-Start:" }; | |
}C | |
sub vcl_recv { | |
# Add X-Request-Start header for New Relic queue time analytics | |
C{ | |
struct timeval detail_time; | |
gettimeofday(&detail_time, NULL); | |
char start[20]; | |
sprintf(start, "t=%lu%06lu", detail_time.tv_sec, detail_time.tv_usec); | |
VRT_SetHdr(ctx, &VGC_HDR_REQ_reqstart, start, vrt_magic_string_end); | |
}C | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add X-Request-Start Header in Varnish 4.x
Based on Varnish 3.x snippet from Tracking request queue time on New Relic RPM with Varnish comment by Disqus user Marcelo IH.
To allow inline-C in the VCL start Varnish with:
varnishd -p vcc_allow_inline_c=on
You can check if it works by looking at:
varnishtop -I ReqHeader:X-Request-Start