/datadog

Dogstatsd client

Primary LanguageGo

Build Status

datadog

-- import "github.com/statsd/datadog"

Package datadog implements a simple dogstatsd client

c, err := Dial(":5000")
c.SetPrefix("myprogram")
c.SetTags("env:stage", "program:myprogram")
c.Incr("count")

Usage

type Client

type Client struct {
	sync.Mutex
}

Client represents a datadog client.

func Dial

func Dial(addr string) (*Client, error)

Dial connects to addr and returns a client.

func DialSize

func DialSize(addr string, size int) (*Client, error)

DialSize connects with the given buffer size. see https://git.io/vzC0D.

func New

func New(w io.Writer) *Client

New returns a new Client with writer w, useful for testing.

func (*Client) Close

func (c *Client) Close() error

Close will flush and close the connection.

func (*Client) Decr

func (c *Client) Decr(name string, tags ...string) error

Decr decrements counter name with tags.

func (*Client) DecrBy

func (c *Client) DecrBy(name string, n int, tags ...string) error

DecrBy decrements counter name by n with optional tags.

func (*Client) Duration

func (c *Client) Duration(name string, d time.Duration, tags ...string) error

Duration uses Histogram() to send the given d duration.

func (*Client) Flush

func (c *Client) Flush() error

Flush will flush the underlying buffer.

func (*Client) Gauge

func (c *Client) Gauge(name string, n int, tags ...string) error

Gauge sets the metric name to n at a given time.

func (*Client) Histogram

func (c *Client) Histogram(name string, v int, tags ...string) error

Histogram measures the statistical distribution of a metric name with the given v value, rate and tags.

func (*Client) Incr

func (c *Client) Incr(name string, tags ...string) error

Incr increments counter name with tags.

func (*Client) IncrBy

func (c *Client) IncrBy(name string, n int, tags ...string) error

IncrBy increments counter name by n with optional tags.

func (*Client) Increment

func (c *Client) Increment(name string, count int, rate float64, tags ...string) error

Increment incremenets the given stat name with the given count, rate and tags....

func (*Client) SetPrefix

func (c *Client) SetPrefix(name string)

SetPrefix sets global prefix name.

func (*Client) SetTags

func (c *Client) SetTags(tags ...string)

SetTags sets global tags tags....

func (*Client) Unique

func (c *Client) Unique(name, value string, tags ...string) error

Unique records a unique occurence of events.