<commit_before>## StastN

[![Build status](https://ci.appveyor.com/api/projects/status/breathpwtv4pjlg9/branch/master?svg=true)](https://ci.appveyor.com/project/tparnell8/statsn/branch/master) [![Coverage Status](https://coveralls.io/repos/github/TerribleDev/StatsN/badge.svg?branch=master)](https://coveralls.io/github/TerribleDev/StatsN?branch=master)

StastN is a modern high performance Stastd client for dotnet core. StatsN supports both TCP and UDP, although UDP is recommended. Largely inspired by the [statsd-csharp-client](https://github.com/Pereingo/statsd-csharp-client) and the [statsd.net client](https://github.com/lukevenediger/statsd-csharp-client). Both projects In my mind are awesome, just not exactly what I was looking for.

I wrote this client, because I found unit testing [statics](https://github.com/Pereingo/statsd-csharp-client) statics less than fun, and tired of waiting for [features to be published](https://github.com/lukevenediger/statsd-csharp-client/issues/17). Also I noticed some statsd clients had features implemented that were unsuported by statsd itself.

This client attempts to help testability by using interfaces, observability by allowing you to register functions to listen for exceptions and logging that occurs inside the client, and scalability by really making the code perform well.

## Getting started

In short the api is easy. You can get a new IStatsd with a few different ways, and then you can log metrics with an IStatsd implementation. Here are some examples.


```csharp
IStatsd statsd = Statsd.New<Udp>(a=>a.hostOrIp = "10.22.2.1", Port = 8125);
IStatsd statsd = Statsd.New<Tcp>(a=>a.hostOrIp = "10.22.2.1"); //use tcp
IStatsd statsd = Statsd.New(a=>a.hostOrIp = "10.22.2.1"); //defaults to udp
IStatsd statsd = Statsd.New(new StatsdOptions(){ hostOrIp = "127.0.0.1"}); //defaults to udp
IStatsd statsd = new Stastd(new StatsdOptions(){ hostOrIp = "127.0.0.1"});  //defaults to udp
IStatsd statsd = new Stastd(new StatsdOptions(){ hostOrIp = "127.0.0.1"}, new Tcp()); //pass a new udp client. You could in theory make your own transport if you inherit from BaseCommunicationProvider


statsd.CountAsync("myapp.counterstat"); //default to 1 aka increment
statsd.CountAsync("myapp.counterstat", 6);
statsd.CountAsync("myapp.counterstat", -6);
statsd.TimerAsync("myapp.timeMyFunction", ()=>{
 //code to instrument
});
statsd.TimerAsync("myapp.timeData", 400); //400ms
statsd.GaugeAsync("autotest.gaugeyo", 422);
statsd.GaugeDeltaAsync("autotest.gaugeyo", -10);
statsd.SetAsync("autotest.setyo", 888);

```

## Logging<commit_msg>finish up readme for now<commit_after>## StastN

[![Build status](https://ci.appveyor.com/api/projects/status/breathpwtv4pjlg9/branch/master?svg=true)](https://ci.appveyor.com/project/tparnell8/statsn/branch/master) [![Coverage Status](https://coveralls.io/repos/github/TerribleDev/StatsN/badge.svg?branch=master)](https://coveralls.io/github/TerribleDev/StatsN?branch=master)

StastN is a modern high performance Stastd client for dotnet core. StatsN supports both TCP and UDP, although UDP is recommended. Largely inspired by the [statsd-csharp-client](https://github.com/Pereingo/statsd-csharp-client) and the [statsd.net client](https://github.com/lukevenediger/statsd-csharp-client). Both projects In my mind are awesome :facepunch:, just not exactly what I was looking for.

I wrote this client, because I found unit testing [statics](https://github.com/Pereingo/statsd-csharp-client) statics less than fun, and tired of waiting for [features to be published](https://github.com/lukevenediger/statsd-csharp-client/issues/17). Or support for [features](https://github.com/lukevenediger/statsd-csharp-client/blob/250f02caaf5fdbf3e112ac57c86d5a8bdb9618c5/StatsdClient/IStatsd.cs#L54) that statsd [does not actually supprt](https://github.com/etsy/statsd/issues/467).

This client attempts to help testability by using interfaces, observability by allowing you to register functions to listen for exceptions and logging that occurs inside the client, and scalability by really making the code perform well.

## Getting started

In short the api is easy. You can get a new IStatsd with a few different ways, and then you can log metrics with an IStatsd implementation. Here are some examples.


```csharp
IStatsd statsd = Statsd.New<Udp>(a=>a.hostOrIp = "10.22.2.1", Port = 8125);
IStatsd statsd = Statsd.New<Tcp>(a=>a.hostOrIp = "10.22.2.1"); //use tcp
IStatsd statsd = Statsd.New(a=>a.hostOrIp = "10.22.2.1"); //defaults to udp
IStatsd statsd = Statsd.New(new StatsdOptions(){ hostOrIp = "127.0.0.1"}); //defaults to udp
IStatsd statsd = new Stastd(new StatsdOptions(){ hostOrIp = "127.0.0.1"});  //defaults to udp
IStatsd statsd = new Stastd(new StatsdOptions(){ hostOrIp = "127.0.0.1"}, new Tcp()); //pass a new udp client. You could in theory make your own transport if you inherit from BaseCommunicationProvider


statsd.CountAsync("myapp.counterstat"); //default to 1 aka increment
statsd.CountAsync("myapp.counterstat", 6);
statsd.CountAsync("myapp.counterstat", -6);
statsd.TimerAsync("myapp.timeMyFunction", ()=>{
 //code to instrument
});
statsd.TimerAsync("myapp.timeData", 400); //400ms
statsd.GaugeAsync("autotest.gaugeyo", 422);
statsd.GaugeDeltaAsync("autotest.gaugeyo", -10);
statsd.SetAsync("autotest.setyo", 888);

```

## Logging
{'fraction_non_alphanumeric': 0.129261895841139, 'fraction_numerical': 0.028100412139378046, 'mean_word_length': 5.266431924882629, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 18, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 12, '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': '278562', 'n_tokens_mistral': 1862, 'n_tokens_neox': 1723, 'n_words': 495}