Skip to content

Instantly share code, notes, and snippets.

@dalyons
Forked from jelder/newrelic.h
Created April 29, 2012 23:41
Show Gist options
  • Save dalyons/2554048 to your computer and use it in GitHub Desktop.
Save dalyons/2554048 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.
C{
#include </etc/varnish/newrelic.h>
}C
sub vcl_recv {
C{
set_x_request_start(sp);
}C
}
/*
* Add X-Request-Start header so we can track queue times in New Relic RPM beginning at Varnish.
* Taken from https://gist.github.com/494265 & modified to compile on OSX.
*/
#include <sys/time.h>
void set_x_request_start(const struct sess *sp) {
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);
}
@dalyons
Copy link
Author

dalyons commented Apr 29, 2012

Had to wrap it in a function - original Gist wont compile on OSX due to disabled support for -fnested-functions CFLAG/

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