<commit_before># For determining hostname
import socket

import logging
log = logging.getLogger(__name__)

class Events():
	def __init__(self):
		self.events = []

	def add(self, service, state, description, ttl, tags=None, metric=None, hostname=socket.gethostname()):
		event = {}
		event['service'] = service
		event['state'] = state
		event['description'] = description
		event['ttl'] = ttl
		event['hostname'] = hostname
		
		if tags is not None:
			event['tags'] = tags

		if metric is not None:
			event['metric'] = metric

		self.events.append(event)
		log.debug("Event added: %s" % (event))

	def send(self, client):
		log.debug("Sending %s events..." % (len(self.events)))
		while len(self.events) > 0:
			event = self.events.pop(0)
			try:
				client.send(event)
			except socket.error:
				log.error("Unable to send event '%s' to %s:%s" % (event['service'], client.host, client.port))

	<commit_msg>Fix fieldname mapping for riemann (should be host, not hostname)<commit_after># For determining hostname
import socket

import logging
log = logging.getLogger(__name__)

class Events():
	def __init__(self):
		self.events = []

	def add(self, service, state, description, ttl, tags=None, metric=None, host=socket.gethostname()):
		event = {}
		event['service'] = service
		event['state'] = state
		event['description'] = description
		event['ttl'] = ttl
		event['host'] = host
		
		if tags is not None:
			event['tags'] = tags

		if metric is not None:
			event['metric'] = metric

		self.events.append(event)
		log.debug("Event added: %s" % (event))

	def send(self, client):
		log.debug("Sending %s events..." % (len(self.events)))
		while len(self.events) > 0:
			event = self.events.pop(0)
			try:
				client.send(event)
			except socket.error:
				log.error("Unable to send event '%s' to %s:%s" % (event['service'], client.host, client.port))

	
{'fraction_non_alphanumeric': 0.15761161915008068, 'fraction_numerical': 0.002151694459386767, 'mean_word_length': 4.054347826086956, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1243955', 'n_tokens_mistral': 683, 'n_tokens_neox': 608, 'n_words': 169}