statsd

package module
v0.0.0-...-50aeaf9 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2015 License: MIT Imports: 7 Imported by: 1

README

StatsD Client

Build Status

This is a no-nonsense StatsD client written in Go. It reconnects automatically if the write socket fails, making it at least 1000% better than any other StatsD client available.

It doesn't support sampling, I'd welcome a good pull request.

Pair it with statsd-librato server for a simple and efficient pipeline to Librato.

Usage

import "github.com/jcoene/statsd-client"

client, err := statsd.NewClient("127.0.0.1:8125", "myapp")

client.Count("http.response.200.count", 1)         // myapp.http.response.200.count:1|c
client.Inc("http.response.200.count", 1)           // myapp.http.response.200.count:1|c
client.Dec("http.response.200.count", 1)           // myapp.http.response.200.count:-1|c
client.Measure("http.response.200.runtime", 50)    // myapp.http.response.200.runtime:50|ms
client.MeasureDur("job.runtime", 50 * time.Second) // myapp.job.runtime:50000|ms
client.Gauge("server.load", 5)                     // myapp.server.load:5|g

You can also establish a default client that can be shared between parts of your app:

import "github.com/jcoene/statsd-client"

err := statsd.NewDefaultClient("127.0.0.1:8125", "myapp")

statsd.Count("http.response.200.count", 1)         // myapp.http.response.200.count:1|c

License

MIT License, see LICENSE file.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NL = []byte("\n")

Functions

func Count

func Count(k string, d int64)

func Dec

func Dec(k string, d int64)

func Gauge

func Gauge(k string, v float64)

func Inc

func Inc(k string, d int64)

func Init

func Init()

func Measure

func Measure(k string, v float64)

func MeasureDur

func MeasureDur(k string, dur time.Duration)

func NewDefaultClient

func NewDefaultClient(addr string, prefix string)

func SetDebug

func SetDebug(b bool)

func SetDelay

func SetDelay(s string)

func Timing

func Timing(k string, v float64)

Types

type Client

type Client struct {
	Addr   string
	Prefix string
	Proto  string
	Delay  time.Duration
	Debug  bool
	// contains filtered or unexported fields
}
var DefaultClient *Client

func NewClient

func NewClient(addr string, prefix string) (c *Client)

func (*Client) Count

func (c *Client) Count(k string, d int64)

func (*Client) Dec

func (c *Client) Dec(k string, d int64)

func (*Client) Gauge

func (c *Client) Gauge(k string, v float64)

func (*Client) Inc

func (c *Client) Inc(k string, d int64)

func (*Client) Measure

func (c *Client) Measure(k string, v float64)

func (*Client) MeasureDur

func (c *Client) MeasureDur(k string, dur time.Duration)

func (*Client) SetDebug

func (c *Client) SetDebug(b bool)

func (*Client) SetDelay

func (c *Client) SetDelay(s string)

func (*Client) SetTCP

func (c *Client) SetTCP()

func (*Client) Timing

func (c *Client) Timing(k string, v float64)

Jump to

Keyboard shortcuts

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