Documentation
¶
Index ¶
- Constants
- Variables
- func AppendMeasure(b []byte, m stats.Measure) []byte
- func AppendMeasureFiltered(b []byte, m stats.Measure, filters map[string]struct{}, distPrefixes []string) []byte
- func ListenAndServe(addr string, handler Handler) (err error)
- func Serve(conn net.PacketConn, handler Handler) (err error)
- type Client
- type ClientConfig
- type Event
- type EventAlertType
- type EventPriority
- type Handler
- type HandlerFunc
- type Metric
- type MetricType
Constants ¶
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 ¶
var ( // DefaultFilters are the default tags 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 filters if there are a static // number of routes. DefaultFilters = []string{"http_req_path"} // DefaultDistributionPrefixes is the default set of name prefixes for // metrics to be sent as distributions instead of as histograms. DefaultDistributionPrefixes = []string{} )
Functions ¶
func AppendMeasure ¶
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{}, distPrefixes []string) []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 ¶
ListenAndServe starts a new dogstatsd server, listening for UDP datagrams on addr 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 ¶
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 (*Client) HandleMeasures ¶
HandleMeasures satisfies the stats.Handler 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
// Set of name prefixes for metrics to be sent as distributions instead of
// as histograms.
DistributionPrefixes []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
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" )
Event Alert Types.
type EventPriority ¶
type EventPriority string
EventPriority is an enumeration providing the available datadog event priority levels.
const ( EventPriorityNormal EventPriority = "normal" EventPriorityLow EventPriority = "low" )
Event Priorities.
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 ¶
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.
type MetricType ¶
type MetricType string
MetricType is an enumeration providing symbols to represent the different metric types supported by datadog.
const ( Counter MetricType = "c" Gauge MetricType = "g" Histogram MetricType = "h" Distribution MetricType = "d" Unknown MetricType = "?" )
Metric Types.