datadog

package
v4.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2018 License: MIT Imports: 14 Imported by: 17

Documentation

Index

Constants

View Source
const (
	// DefaultAddress is the default address to which the datadog client tries
	// to connect to.
	DefaultAddress = "localhost:8125"

	// DefaultBufferSize is the default size for batches of metrics sent to
	// datadog.
	DefaultBufferSize = 1024

	// MaxBufferSize is a hard-limit on the max size of the datagram buffer.
	MaxBufferSize = 65507
)

Variables

View Source
var (
	DefaultFilters = []string{"http_req_path"}
)

DefaultFilter is the default tag to filter before sending to datadog. Using the request path as a tag can overwhelm datadog's servers if there are too many unique routes due to unique IDs being a part of the path. Only change the default filter if there is a static number of routes.

Functions

func AppendMeasure

func AppendMeasure(b []byte, m stats.Measure) []byte

AppendMeasure is a formatting routine to append the dogstatsd protocol representation of a measure to a memory buffer.

func AppendMeasureFiltered

func AppendMeasureFiltered(b []byte, m stats.Measure, filters map[string]struct{}) []byte

AppendMeasureFiltered is a formatting routine to append the dogstatsd protocol representation of a measure to a memory buffer. Tags listed in the filters map are removed. (some tags may not be suitable for submission to DataDog)

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 an datadog client that implements the stats.Handler interface.

func NewClient

func NewClient(addr string) *Client

NewClient creates and returns a new datadog client publishing metrics to the server running at addr.

func NewClientWith

func NewClientWith(config ClientConfig) *Client

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

func (*Client) AppendMeasures

func (s *Client) AppendMeasures(b []byte, _ time.Time, measures ...stats.Measure) []byte

func (*Client) Close

func (c *Client) Close() error

Close flushes and closes the client, satisfies the io.Closer interface.

func (*Client) Flush

func (c *Client) Flush()

Flush satisfies the stats.Flusher interface.

func (*Client) HandleMeasures

func (c *Client) HandleMeasures(time time.Time, measures ...stats.Measure)

HandleMetric satisfies the stats.Handler interface.

func (*Client) Write

func (c *Client) Write(b []byte) (int, error)

Write satisfies the io.Writer interface.

type ClientConfig

type ClientConfig struct {
	// Address of the datadog database to send metrics to.
	Address string

	// Maximum size of batch of events sent to datadog.
	BufferSize int

	// List of tags to filter. If left nil is set to DefaultFilters.
	Filters []string
}

The ClientConfig type is used to configure datadog clients.

type Event

type Event struct {
	Title          string
	Text           string
	Ts             int64
	Priority       EventPriority
	Host           string
	Tags           []stats.Tag
	AlertType      EventAlertType
	AggregationKey string
	SourceTypeName string
	EventType      string
}

Event is a representation of a datadog event

func (Event) Format

func (e Event) Format(f fmt.State, _ rune)

Format satisfies the fmt.Formatter interface.

func (Event) String

func (e Event) String() string

String satisfies the fmt.Stringer interface.

type EventAlertType

type EventAlertType string

EventAlertType is an enumeration providing the available datadog event allert types.

const (
	EventAlertTypeError   EventAlertType = "error"
	EventAlertTypeWarning EventAlertType = "warning"
	EventAlertTypeInfo    EventAlertType = "info"
	EventAlertTypeSuccess EventAlertType = "success"
)

type EventPriority

type EventPriority string

EventPriority is an enumeration providing the available datadog event priority levels.

const (
	EventPriorityNormal EventPriority = "normal"
	EventPriorityLow    EventPriority = "low"
)

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)

	// HandleEvent is called when a dogstatsd server receives an event.
	// The method receives the metric and the address from which it was sent.
	HandleEvent(Event, 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) HandleEvent

func (f HandlerFunc) HandleEvent(e Event, a net.Addr)

HandleEvent is a no-op for backwards compatibility.

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