<commit_before>﻿using System;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Text;

namespace StatsSharp
{
	public interface IGraphiteClient
	{
		void Send(GraphiteValue value);
		void Send(IEnumerable<GraphiteValue> values);
	}

	public class GraphiteTextClient : IDisposable, IGraphiteClient
	{
		static readonly byte[] RecordSeparator = { (byte)'\n' };

		readonly Socket socket;

		GraphiteTextClient(string host, int port) {
			this.socket = new Socket(SocketType.Stream, ProtocolType.IP);
			socket.Connect(host, port);
		}

		public static GraphiteTextClient Create(string host, int port = 2003) {
			return new GraphiteTextClient(host, port);
		}

		public void Send(GraphiteValue value) {
			socket.Send(value.GetBytes(Encoding.ASCII));
			socket.Send(RecordSeparator);
		}

		public void Send(IEnumerable<GraphiteValue> values) {
			foreach(var item in values)
				Send(item);
		}

		public void Close() {
			socket.Close();
		}

		void IDisposable.Dispose() {
			socket.Dispose();
		}
	}
}<commit_msg>Switched default encoding, made it stats client compatible.<commit_after>using System;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Text;

namespace StatsSharp
{
	public interface IGraphiteClient
	{
		void Send(GraphiteValue value);
		void Send(IEnumerable<GraphiteValue> values);
	}

	public class GraphiteTextClient : IDisposable, IGraphiteClient, IStatsClient
	{
		static readonly byte[] RecordSeparator = { (byte)'\n' };

		readonly Socket socket;

		public Encoding Encoding => Encoding.UTF8;

		GraphiteTextClient(string host, int port) {
			this.socket = new Socket(SocketType.Stream, ProtocolType.IP);
			socket.Connect(host, port);
		}

		public static GraphiteTextClient Create(string host, int port = 2003) =>
			new GraphiteTextClient(host, port);

		public void Send(GraphiteValue value) {
			socket.Send(value.GetBytes(Encoding));
			socket.Send(RecordSeparator);
		}

		public void Send(IEnumerable<GraphiteValue> values) {
			foreach(var item in values)
				Send(item);
		}

		public void Close() =>
			socket.Close();

		void IDisposable.Dispose() =>
			socket.Dispose();

		public void Send(Metric metric) =>
			Send(new GraphiteValue(metric.Name, metric.Value.AsDouble(), DateTime.UtcNow));

		public void Send(IEnumerable<Metric> metrics)
		{
			var now = DateTime.UtcNow;
			foreach(var item in metrics)
				Send(new GraphiteValue(item.Name, item.Value.AsDouble(), now));
		}
	}
}
{'fraction_non_alphanumeric': 0.10985002026753142, 'fraction_numerical': 0.0036481556546412645, 'mean_word_length': 4.508928571428571, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 13, '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': '1762041', 'n_tokens_mistral': 873, 'n_tokens_neox': 757, 'n_words': 186}