var Graphite = require('graphite');
var Measured = require('measured');

var reportInterval = 5000;
var graphiteHost = process.env.GRAPHITE_HOST || null;
var graphitePort = process.env.GRAPHITE_PORT || 2003;
var envName = process.env.ENV_NAME || "unknown";

var timer = null;
var graphite = null;
var data = Measured.createCollection('origami.polyfill.' + envName);

if (graphiteHost) {
	graphite = Graphite.createClient('plaintext://'+graphiteHost+':'+graphitePort);
	timer = setInterval(function() {
		graphite.write(data.toJSON(), function(err) {
			if (err) {
				console.error(err);
			}
		});
	}, reportInterval);
	timer.unref();
}

module.exports = data;

@@ -547,42 +547,206 @@
 ) %7B%0A
-%09%09%09if (err) %7B%0A%09%09%09%09console.error(er
+%0A%09%09%09// Ignore timeouts%0A%09%09%09if (err.code === 'ETIMEDOUT') return;%0A%0A%09%09%09if (err) %7B%0A%09%09%09%09console.error(err, err.stack);%0A%09%09%09%09console.warn('Disabling graphite reporting due to error');%0A%09%09%09%09clearTimeout(time
 r);%0A

Handle graphite reporting timeouts