<commit_before>// Client library for statsd.
package statsd

import (
	"bufio"
	"fmt"
	"io"
	"math/rand"
	"net"
	"time"
)

// A statsd client representing a connection to a statsd server.
type Client struct {
	Name string
	rw   *bufio.ReadWriter
}

func millisecond(d time.Duration) int {
	return int(d.Seconds() * 1000)
}

// Dial connects to the given address on the given network using net.Dial and then returns a new Client for the connection.
func Dial(addr string) (*Client, error) {
	rw, err := net.Dial("udp", addr)
	if err != nil {
		return nil, err
	}
	return newClient(addr, rw), nil
}

func newClient(name string, rw io.ReadWriter) *Client {
	c := new(Client)
	c.Name = name
	c.rw = bufio.NewReadWriter(bufio.NewReader(rw), bufio.NewWriter(rw))
	return c
}

// Increment the counter for the given bucket
func (c *Client) Increment(stat string, count int, rate float64) error {
	return c.send(stat, rate, "%d|c", count)
}<commit_msg>add DialTimeout<commit_after>// Client library for statsd.
package statsd

import (
	"bufio"
	"fmt"
	"io"
	"math/rand"
	"net"
	"time"
)

// A statsd client representing a connection to a statsd server.
type Client struct {
	Name string
	rw   *bufio.ReadWriter
}

func millisecond(d time.Duration) int {
	return int(d.Seconds() * 1000)
}

// Dial connects to the given address on the given network using net.Dial and then returns a new Client for the connection.
func Dial(addr string) (*Client, error) {
	rw, err := net.Dial("udp", addr)
	if err != nil {
		return nil, err
	}
	return newClient(addr, rw), nil
}

func DialTimeout(addr string, timeout time.Duration) (*Client, error) {
	rw, err := net.DialTimeout("udp", addr, timeout)
	if err != nil {
		return nil, err
	}
	return newClient(addr, rw), nil
}

func newClient(name string, rw io.ReadWriter) *Client {
	c := new(Client)
	c.Name = name
	c.rw = bufio.NewReadWriter(bufio.NewReader(rw), bufio.NewWriter(rw))
	return c
}

// Increment the counter for the given bucket
func (c *Client) Increment(stat string, count int, rate float64) error {
	return c.send(stat, rate, "%d|c", count)
}
{'fraction_non_alphanumeric': 0.12416107382550336, 'fraction_numerical': 0.005752636625119847, 'mean_word_length': 4.004796163069544, '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': '7162861', 'n_tokens_mistral': 755, 'n_tokens_neox': 738, 'n_words': 253}