Created
July 28, 2010 12:10
-
-
Save jelder/494265 to your computer and use it in GitHub Desktop.
Add X-Request-Start header so we can track queue times in New Relic RPM beginning at Varnish.
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
/* | |
* Add X-Request-Start header so we can track queue times in New Relic RPM beginning at Varnish. | |
* | |
*/ | |
#include <sys/time.h> | |
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(sp, HDR_REQ, "\020X-Request-Start:", start, vrt_magic_string_end); | |
If you are using Varnish 3.0 you need to place the C includes outside of the VCL blocks.
........
C{
#include <syslog.h>
#include <sys/time.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
}C
sub vcl_recv {
C{
struct timeval detail_time;
gettimeofday(&detail_time,NULL);
char start[20];
sprintf(start, "%lu%06lu", detail_time.tv_sec, detail_time.tv_usec);
VRT_SetHdr(sp, HDR_REQ, "\020X-Request-Start:", start, vrt_magic_string_end);
}C
........
sub vcl_deliver {
set resp.http.X-ID = req.xid;
}
.......
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@trivoallan Did you ever uncover the answer?