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); | |
This code does not seem to work anymore. Here's what varnish says :
# varnish_reload_vcl
Loading vcl from /etc/varnish/default.vcl
Current running config name is reload_2012-06-14T15:46:25
Using new config name reload_2012-06-28T16:59:48
Message from C-compiler:
In file included from ./vcl.YttVe_cv.c:489:
/etc/varnish/newrelic.h: In function ‘VGC_function_vcl_recv’:
/etc/varnish/newrelic.h:9: erreur: ‘NULL’ undeclared (first use in this function)
/etc/varnish/newrelic.h:9: erreur: (Each undeclared identifier is reported only once
/etc/varnish/newrelic.h:9: erreur: for each function it appears in.)
/etc/varnish/newrelic.h:11: attention : implicit declaration of function ‘sprintf’
/etc/varnish/newrelic.h:11: attention : incompatible implicit declaration of built-in function ‘sprintf’
Running C-compiler failed, exit 1
VCL compilation failed
Command failed with error code 106
@trivollan I am not currently running Varnish or New Relic in production, but I'm sure the folks on the mailing list or IRC (#varnish on irc.linpro.no) can point out what's changed since I wrote this.
Thanks the fast answer. I'll go and see if i can find help there.
@trivoallan Did you ever uncover the answer?
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
Save to /etc/varnish/newrelic.h and add the following to your vcl_recv declaration in default.vcl.