func (c *StatsdClient) CreateSocket() error {
	conn, err := net.DialTimeout(string(udpSocket), c.addr, 5*time.Second)
	if err != nil {
		return err
	}
	c.conn = conn
	c.sockType = udpSocket
	return nil
}
CreateSocket creates a UDP connection to a StatsD server
package statsd
import (
	"errors"
	"fmt"
	"log"
	"math/rand"
	"net"
	"os"
	"strings"
	"time"
	"github.com/quipo/statsd/event"
)
type Logger interface {
	Println(v ...interface{})
}
var UDPPayloadSize = 512
var Hostname string
var errNotConnected = fmt.Errorf("cannot send stats, not connected to StatsD server")
var (
	ErrInvalidCount      = errors.New("count is less than 0")
	ErrInvalidSampleRate = errors.New("sample rate is larger than 1 or less then 0")
)
func init() {
	if host, err := os.Hostname(); nil == err {
		Hostname = host
	}
}
type socketType string
const (
	udpSocket socketType = "udp"
	tcpSocket socketType = "tcp"
)
type StatsdClient struct {
	conn     net.Conn
	addr     string
	prefix   string
	sockType socketType
	Logger   Logger
}
func NewStatsdClient(addr string, prefix string) *StatsdClient {
	prefix = strings.Replace(prefix, "%HOST%", Hostname, 1)
	return &StatsdClient{
		addr:   addr,
		prefix: prefix,
		Logger: log.New(os.Stdout, "[StatsdClient] ", log.Ldate|log.Ltime),
	}
}
func (c *StatsdClient) String() string {
	return c.addr
}