<commit_before>(function() {
	'use strict';

	var dgram = require('dgram'),
		client = dgram.createSocket('udp4'),
		started = false,
		cache = {};

	exports.incrementCounter = function (config, name, value) {
		if (!config || !config.name || !config.fluentd || !config.fluentd.host || !config.fluentd.port) {
			return;
		}

		cache[config.name.replace(/\s/g, '-') + '.' + name + '.counter'] = Number(value);

		if (!started) {
			start();
		}
	};

	function start() {
		if (started) {
			return;
		}
		started = true;

		client.on('error', function () {
			client.close();
		});

		setInterval(send, config.fluentd.sendInterval || 1000);
	}

	function send() {
		var message = new Buffer(JSON.stringify(cache));

		cache = {};


		client.send(message, 0, message.length, config.fluentd.port, config.fluentd.host, function () {
			client.close();
		});
	}
})();<commit_msg>implement fluentd send buffering - add unref to interval<commit_after>(function() {
	'use strict';

	var dgram = require('dgram'),
		client = dgram.createSocket('udp4'),
		started = false,
		cache = {};

	exports.incrementCounter = function (config, name, value) {
		if (!config || !config.name || !config.fluentd || !config.fluentd.host || !config.fluentd.port) {
			return;
		}

		cache[config.name.replace(/\s/g, '-') + '.' + name + '.counter'] = Number(value);

		if (!started) {
			start();
		}
	};

	function start() {
		if (started) {
			return;
		}
		started = true;

		client.on('error', function () {
			client.close();
		});

		setInterval(send, config.fluentd.sendInterval || 1000).unref();
	}

	function send() {
		var message = new Buffer(JSON.stringify(cache));

		cache = {};


		client.send(message, 0, message.length, config.fluentd.port, config.fluentd.host, function () {
			client.close();
		});
	}
})();
{'fraction_non_alphanumeric': 0.1934408004446915, 'fraction_numerical': 0.006670372429127293, 'mean_word_length': 3.488778054862843, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1918529', 'n_tokens_mistral': 716, 'n_tokens_neox': 622, 'n_words': 121}