<commit_before>gostatsd
========

gostatsd is a Statsd client package for Go. It supports all commands supported
by the [etsy/statsd](https://github.com/etsy/statsd/) project and automatically
buffers stats into 512 byte UDP packets.

[Documentation](http://godoc.org/github.com/stvp/gostatsd)

Usage
-----

gostatsd, by default, buffers up to 512 bytes of data before sending a UDP
packet. This means that you need to manually call `Flush()` after you're done
recording your stats to send any remaining stats.

```go
package main

import (
	"github.com/stvp/gostatsd"
	"math"
	"time"
)

func main() {
	client := statsd.New("127.0.0.1:8125", "some.prefix.")
	defer client.Flush()

	// Counters
	for i := 0; i < 10000; i++ {
		// ...
		if math.Mod(i, 100) == 0 {
			client.Count("transactions", 1, 0.100)
		}
	}

	// Gauges
	client.Gauge("queuesize", 28)

	// Timers
	start := time.Now()
	// ...
	client.Timing("methodtime", time.Since(start))
}
```

The buffer size (in bytes) can be customized:

```go
client := NewWithPacketSize("my.prefix.", 128)
```

### Unbuffered sending

A buffer size of 0 or less will cause all stats to be sent individually as soon
as they are received. (This also means that you wont need to call `Flush`.)

```go
client := NewWithPacketSize("my.prefix.", -1)
```
<commit_msg>Fix examples in readme.<commit_after>gostatsd
========

gostatsd is a Statsd client package for Go. It supports all commands supported
by the [etsy/statsd](https://github.com/etsy/statsd/) project and automatically
buffers stats into 512 byte UDP packets.

[Documentation](http://godoc.org/github.com/stvp/gostatsd)

Usage
-----

gostatsd, by default, buffers up to 512 bytes of data before sending a UDP
packet. This means that you need to manually call `Flush()` after you're done
recording your stats to send any remaining stats.

```go
package main

import (
	"github.com/stvp/gostatsd"
	"math"
	"time"
)

func main() {
	client := statsd.New("127.0.0.1:8125", "some.prefix.")
	defer client.Flush()

	// Counters
	for i := 0; i < 10000; i++ {
		// ...
		if math.Mod(i, 100) == 0 {
			client.Count("transactions", 1, 0.100)
		}
	}

	// Gauges
	client.Gauge("queuesize", 28)

	// Timers
	start := time.Now()
	// ...
	client.Timing("methodtime", time.Since(start))
}
```

The buffer size (in bytes) can be customized:

```go
client := NewWithPacketSize("127.0.0.1:8125", "my.prefix.", 128)
```

### Unbuffered sending

A buffer size of 0 or less will cause all stats to be sent individually as soon
as they are received. (This also means that you wont need to call `Flush`.)

```go
client := NewWithPacketSize("127.0.0.1:8125", "my.prefix.", -1)
```

{'fraction_non_alphanumeric': 0.15259984928409948, 'fraction_numerical': 0.03617181612660136, 'mean_word_length': 3.6660808435852372, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '3644348', 'n_tokens_mistral': 1025, 'n_tokens_neox': 912, 'n_words': 303}