Documentation ¶
Index ¶
- Constants
- Variables
- func ListenAndServe(addr string, handler Handler) (err error)
- func Serve(conn net.PacketConn, handler Handler) error
- type Client
- func (s *Client) AppendMeasure(b []byte, m stats.Measure) []byte
- func (s *Client) AppendMeasures(b []byte, _ time.Time, measures ...stats.Measure) []byte
- func (c *Client) Close() error
- func (c *Client) Flush()
- func (c *Client) HandleMeasures(time time.Time, measures ...stats.Measure)
- func (c *Client) Write(b []byte) (int, error)
- 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 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) AppendMeasure ¶
AppendMeasure is a formatting routine to append the dogstatsd protocol representation of a measure to a memory buffer. Tags listed in the s.filters are removed. (some tags may not be suitable for submission to DataDog) Histogram metrics will be sent as distribution type if the metric name matches s.distPrefixes DogStatsd Protocol Docs: https://docs.datadoghq.com/developers/dogstatsd/datagram_shell?tab=metrics#the-dogstatsd-protocol
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. // UDP: host:port (default) // UDS: unixgram://dir/file.ext 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 // UseDistributions True indicates to send histograms with `d` type instead of `h` type // https://docs.datadoghq.com/developers/dogstatsd/datagram_shell?tab=metrics#the-dogstatsd-protocol UseDistributions bool }
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(Event, 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.