Skip to content

Instantly share code, notes, and snippets.

@mago0
Created May 4, 2017 20:39
Show Gist options
  • Save mago0/8628736dbe1d3b4218eaeb351b702a2c to your computer and use it in GitHub Desktop.
Save mago0/8628736dbe1d3b4218eaeb351b702a2c to your computer and use it in GitHub Desktop.
var gor = require("goreplay_middleware");
var statsd = require('dogstatsd-node').StatsD,
client = new statsd();
gor.init();
gor.on("request", function(req) {
// Don't process healthchecks
if (gor.httpPath(req.http) != '/ping') {
let http_host = req.http.toString().match(/^host: (.*)/m)[1].trim();
let http_method = req.http.toString().match(/^(\w+)/m)[0].trim();
let http_path = gor.httpPath(req.http).replace(/\?.*/, '').trim();
let include_verticals = [
'www.flowrestling.org',
'www.flocheer.com',
'www.flograppling.com',
'www.flocombat.com',
'www.flotrack.org'
];
if (include_verticals.includes(http_host)) {
client.increment('goreplay_core.capture', 1).tags([`'http-host:${http_host}'`,`'http-method:${http_method}'`,`'http-route:${http_path}'`]).send();
}
}
// Return nothing - drops all requests from middleware output
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment