datadog

package
v3.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxBufferSize is a hard-limit on the max size of the datagram buffer.
	MaxBufferSize = 65507

	// DefaultAddress is the default address to which clients connection to.
	DefaultAddress = "localhost:8125"

	// DefaultBufferSize is the default size of the client buffer.
	DefaultBufferSize = 1024

	// DefaultFlushInterval is the default interval at which clients flush
	// metrics from their stats engine.
	DefaultFlushInterval = 1 * time.Second
)

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(addr string, handler Handler) (err error)

ListenAndServe starts a new dogstatsd server, listening for UDP datagrams on addr and forwarding the metrics to handler.

func Serve

func Serve(conn net.PacketConn, handler Handler) (err error)

Serve runs a dogstatsd server, listening for datagrams on conn and forwarding the metrics to handler.

Types

type Client

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

Client represents a datadog client that pulls metrics from a stats engine and forward them to a dogstatsd agent.

func NewClient

func NewClient(addr string) *Client

NewClient creates and returns a new datadog client publishing metrics to the dogstatsd server listening for UDP datagram at addr.

func NewClientWith

func NewClientWith(config ClientConfig) *Client

NewClientWith creates and returns a new datadog client configured with config.

func (*Client) Close

func (c *Client) Close() (err error)

Close satisfies the io.Closer interface.

func (*Client) Flush

func (c *Client) Flush()

Flsuh satisfies the stats.Flusher interface.

func (*Client) HandleMetric

func (c *Client) HandleMetric(m *stats.Metric)

HandleMetric satisfies the stats.Handler interface.

type ClientConfig

type ClientConfig struct {
	// Address of the dogstatsd agent to send metrics to.
	Address string

	// BufferSize is the size of the output buffer used by the client.
	BufferSize int
}

The ClientConfig type is used to configure datadog clients.

type Conn

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

A Conn represents a UDP connection to a dogstatsd server.

func Dial

func Dial(address string) (conn *Conn, err error)

Dial opens a new dogstatsd connection to address.

func DialConfig

func DialConfig(config ConnConfig) (conn *Conn, err error)

DialConfig opens a new dogstatsd connection using config.

func NewConn

func NewConn(conn net.Conn, buff []byte) *Conn

NewConn creates a new dogstatsd connection with conn and buff.

func (*Conn) Close

func (c *Conn) Close() (err error)

Close satisfies the net.Conn interface.

func (*Conn) Flush

func (c *Conn) Flush() (err error)

Flush sends a UDP datagram containing all buffered data.

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

LocalAddr satisfies the net.Conn interface.

func (*Conn) Read

func (c *Conn) Read(b []byte) (int, error)

Read satisfies the net.Conn interface.

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

RemoteAddr satisfies the net.Conn interface.

func (*Conn) SetDeadline

func (c *Conn) SetDeadline(t time.Time) error

SetDeadline satisfies the net.Conn interface.

func (*Conn) SetReadDeadline

func (c *Conn) SetReadDeadline(t time.Time) error

SetReadDeadline satisfies the net.Conn interface.

func (*Conn) SetWriteDeadline

func (c *Conn) SetWriteDeadline(t time.Time) error

SetWriteDeadline satisfies the net.Conn interface.

func (*Conn) Write

func (c *Conn) Write(b []byte) (n int, err error)

Write satisfies the net.Conn interface.

type ConnConfig

type ConnConfig struct {
	Address    string
	BufferSize int
}

ConnConfig carries the configuration options that can be set when creating a connection.

type Handler

type Handler interface {
	// HandleMetric is called when a dogstatsd server receives a metric.
	// The method receives the metric and the address from which it was sent.
	HandleMetric(Metric, net.Addr)
}

Handler defines the interface that types must satisfy to process metrics received by a dogstatsd server.

type HandlerFunc

type HandlerFunc func(Metric, net.Addr)

HandlerFunc makes it possible for function types to be used as metric handlers on dogstatsd servers.

func (HandlerFunc) HandleMetric

func (f HandlerFunc) HandleMetric(m Metric, a net.Addr)

HandleMetric calls f(m, a).

type Metric

type Metric struct {
	Type      MetricType  // the metric type
	Namespace string      // the metric namespace (never populated by parsing operations)
	Name      string      // the metric name
	Value     float64     // the metric value
	Rate      float64     // sample rate, a value between 0 and 1
	Tags      []stats.Tag // the list of tags set on the metric
}

The Metric type is a representation of the metrics supported by datadog.

func (Metric) Format

func (m Metric) Format(f fmt.State, _ rune)

Format satisfies the fmt.Formatter interface.

func (Metric) String

func (m Metric) String() string

String satisfies the fmt.Stringer interface.

type MetricType

type MetricType string

MetricType is an enumeration providing symbols to represent the different metric types upported by datadog.

const (
	Counter   MetricType = "c"
	Gauge     MetricType = "g"
	Histogram MetricType = "h"
	Unknown   MetricType = "?"
)

Jump to

Keyboard shortcuts

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