Documentation
¶
Index ¶
- Constants
- Variables
- func AppendMeasure(b []byte, m stats.Measure) []byte
- func AppendMeasureFiltered(b []byte, m stats.Measure, filters map[string]struct{}) []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 = []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 ¶
AppendMeasure is a formatting routine to append the dogstatsd protocol representation of a measure to a memory buffer.
func AppendMeasureFiltered ¶
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.
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 ¶
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) Close ¶
Close flushes and closes the client, satisfies the io.Closer interface.
func (*Client) HandleMeasures ¶
HandleMetric 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
}
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 ¶
Format satisfies the fmt.Formatter 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 ¶
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 ¶
Format satisfies the fmt.Formatter 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 = "?" )
Source Files
¶
- append.go
- client.go
- event.go
- measure.go
- metric.go
- parse.go
- server.go