statsd

package module
v0.0.0-...-6ecba3e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2014 License: MIT Imports: 7 Imported by: 0

README

statsd

statsd is a client library for statsd written in Go.

Installation

Download and install :

$ go get github.com/cyberdelia/statsd

Add it to your code :

import "github.com/cyberdelia/statsd"

Use

c := statsd.Dial("localhost:8125")
c.Increment("incr", 1, 1)
c.Decrement("decr", 1, 0.1)
c.Timing("timer", 320, 0.1)
c.Time("timer", 0.1, func() {
        // do something  
})
c.Gauge("gauge", 30, 1)
c.Unique("unique", 765, 1)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is statsd client representing a connection to a statsd server.

func Dial

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

Dial connects to the given address on the given network using net.Dial and then returns a new Client for the connection.

func DialSize

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

DialSize acts like Dial but takes a packet size. By default, the packet size is 512, see https://github.com/etsy/statsd/blob/master/docs/metric_types.md#multi-metric-packets for guidelines.

func DialTimeout

func DialTimeout(addr string, timeout time.Duration) (*Client, error)

DialTimeout acts like Dial but takes a timeout. The timeout includes name resolution, if required.

func NewClient

func NewClient(w io.Writer) *Client

NewClient returns a new client with the given writer, useful for testing.

func (*Client) Annotate

func (c *Client) Annotate(name string, value string, args ...interface{}) error

Annotate sends an annotation.

func (*Client) Close

func (c *Client) Close() error

Close closes the connection.

func (*Client) Decr

func (c *Client) Decr(stat string) error

Decr decrements the counter for the given bucket by 1 at a rate of 1.

func (*Client) DecrBy

func (c *Client) DecrBy(stat string, value int) error

DecrBy decrements the counter for the given bucket by N at a rate of 1.

func (*Client) Decrement

func (c *Client) Decrement(stat string, count int, rate float64) error

Decrement decrements the counter for the given bucket.

func (*Client) DecrementGauge

func (c *Client) DecrementGauge(stat string, value int, rate float64) error

DecrementGauge decrements the value of the gauge.

func (*Client) DecrementGaugeBy

func (c *Client) DecrementGaugeBy(stat string, value int) error

DecrementGaugeBy decrements the value of the gauge.

func (*Client) Duration

func (c *Client) Duration(stat string, duration time.Duration, rate float64) error

Duration records time spent for the given bucket with time.Duration.

func (*Client) DurationSince

func (c *Client) DurationSince(stat string, t time.Time) error

DurationSince records time spent for the given bucket since `t`.

func (*Client) Flush

func (c *Client) Flush() error

Flush does nothing at the moment, pending new buffer implementation.

func (*Client) Gauge

func (c *Client) Gauge(stat string, value int, rate float64) error

Gauge records arbitrary values for the given bucket.

func (*Client) Histogram

func (c *Client) Histogram(stat string, value int, rate float64) error

Histogram is an alias of .Timing() until statsd implementations figure their shit out.

func (*Client) Incr

func (c *Client) Incr(stat string) error

Incr increments the counter for the given bucket by 1 at a rate of 1.

func (*Client) IncrBy

func (c *Client) IncrBy(stat string, n int) error

IncrBy increments the counter for the given bucket by N at a rate of 1.

func (*Client) Increment

func (c *Client) Increment(stat string, count int, rate float64) error

Increment increments the counter for the given bucket.

func (*Client) IncrementGauge

func (c *Client) IncrementGauge(stat string, value int, rate float64) error

IncrementGauge increments the value of the gauge.

func (*Client) IncrementGaugeBy

func (c *Client) IncrementGaugeBy(stat string, value int) error

IncrementGaugeBy increments the value of the gauge.

func (*Client) Prefix

func (c *Client) Prefix(s string)

Prefix adds a prefix to every stat string. The prefix is literal, so if you want "foo.bar.baz" from "baz" you should set the prefix to "foo.bar." not "foo.bar" as no delimiter is added for you.

func (*Client) Time

func (c *Client) Time(stat string, rate float64, f func()) error

Time calculates time spent in given function and send it.

func (*Client) Timing

func (c *Client) Timing(stat string, delta int, rate float64) error

Timing records time spent for the given bucket in milliseconds.

func (*Client) Unique

func (c *Client) Unique(stat string, value int, rate float64) error

Unique records unique occurences of events.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL