Skip to content

Instantly share code, notes, and snippets.

@alanmackenzie
Forked from jelder/newrelic.h
Created May 28, 2012 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save alanmackenzie/2820068 to your computer and use it in GitHub Desktop.
Save alanmackenzie/2820068 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. - Fixed for Varnish 3.0.2-1 on Ubuntu.
/*
* In varnish 3.0 the includes must be outside a subroutine.
*/
C{
#include <stddef.h>
#include <sys/time.h>
}C
sub vcl_recv {
/*
* Add X-Request-Start header so we can track queue times in New Relic RPM beginning at Varnish.
*
*/
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(sp, HDR_REQ, "\020X-Request-Start:", start, vrt_magic_string_end);
}C
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment