statsd

package
v0.0.0-...-3fb0a0f Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2014 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package statsd provides a StatsD client implementation that is safe for concurrent use by multiple goroutines and for efficiency can be created and reused.

Example usage:

// first create a client
client, err := statsd.New("127.0.0.1:8125", "test-client")
// handle any errors
if err != nil {
	log.Fatal(err)
}
// make sure to clean up
defer client.Close()

// Send a stat
err = client.Inc("stat1", 42, 1.0)
// handle any errors
if err != nil {
	log.Printf("Error sending metric: %+v", err)
}

Index

Examples

Constants

This section is empty.

Variables

View Source
var Dial = New

Compat

Functions

This section is empty.

Types

type Client

type Client interface {
	// Close closes the connection and cleans up.
	Close() error

	// Increments a statsd count type.
	// stat is a string name for the metric.
	// value is the integer value
	// rate is the sample rate (0.0 to 1.0)
	Inc(stat string, value int64, rate float32) error

	// Decrements a statsd count type.
	// stat is a string name for the metric.
	// value is the integer value.
	// rate is the sample rate (0.0 to 1.0).
	Dec(stat string, value int64, rate float32) error

	// Submits/Updates a statsd gauge type.
	// stat is a string name for the metric.
	// value is the integer value.
	// rate is the sample rate (0.0 to 1.0).
	Gauge(stat string, value int64, rate float32) error

	// Submits a delta to a statsd gauge.
	// stat is the string name for the metric.
	// value is the (positive or negative) change.
	// rate is the sample rate (0.0 to 1.0).
	GaugeDelta(stat string, value int64, rate float32) error

	// Submits a statsd timing type.
	// stat is a string name for the metric.
	// value is the integer value.
	// rate is the sample rate (0.0 to 1.0).
	Timing(stat string, delta int64, rate float32) error

	// Submits a stats set type, where value is the unique string
	// rate is the sample rate (0.0 to 1.0).
	UniqueString(stat string, value string, rate float32) error

	// Submits a stats set type
	// rate is the sample rate (0.0 to 1.0).
	UniqueInt64(stat string, value int64, rate float32) error

	// Sets/Updates the statsd client prefix
	SetPrefix(prefix string)
}
Example
// first create a client
client, err := Dial("127.0.0.1:8125", "test-client")
// handle any errors
if err != nil {
	log.Fatal(err)
}
// make sure to clean up
defer client.Close()

// Send a stat
err = client.Inc("stat1", 42, 1.0)
// handle any errors
if err != nil {
	log.Printf("Error sending metric: %+v", err)
}
Output:

func New

func New(addr, prefix string) (Client, error)

Returns a pointer to a new Client, and an error. addr is a string of the format "hostname:port", and must be parsable by net.ResolveUDPAddr. prefix is the statsd client prefix. Can be "" if no prefix is desired.

func NewNop

func NewNop() Client

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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