Skip to content

Instantly share code, notes, and snippets.

@b3cft
Created September 20, 2012 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b3cft/3754524 to your computer and use it in GitHub Desktop.
Save b3cft/3754524 to your computer and use it in GitHub Desktop.
Add header to requests on a sample rate
// at head of vcl
C{
static __thread struct drand48_data random_seed;
static long int sample_rate = 1000;
}C
// in vcl recv
C{
long int r;
lrand48_r(&random_seed, &r);
if (0 == r % sample_rate) {
// add header
}
}C
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment