Documentation ¶
Overview ¶
Simple client to the [Datadog API](http://docs.datadoghq.com/api/).
Datadog reporter for the [go-metrics](https://github.com/rcrowley/go-metrics) library.
Index ¶
Constants ¶
const ( ENDPOINT = "https://app.datadoghq.com/api" SERIES_ENDPIONT = "/v1/series" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
func New ¶
Create a new Datadog client. In EC2, datadog expects the hostname to be the instance ID rather than `gethostname(2)`. However, that value can be obtained with `os.Hostname()`.
func (*Client) DefaultReporter ¶
func (c *Client) DefaultReporter() *MetricsReporter
Create a `MetricsReporter` configured to use metric's default registry. This reporter will not be started.
func (*Client) PostSeries ¶
Posts an array of series data to the Datadog API. The API expects an object, not an array, so it will be wrapped in a `seriesMessage` with a single `series` field.
func (*Client) Reporter ¶
func (c *Client) Reporter(reg metrics.Registry) *MetricsReporter
Create a `MetricsReporter` for the given metrics reporter. The returned reporter will not be started.
func (*Client) SeriesUrl ¶
Gets an authenticated URL to POST series data to. In Datadog's examples, this value is 'https://app.datadoghq.com/api/v1/series?api_key=9775a026f1ca7d1...'
type MetricsReporter ¶
type MetricsReporter struct {
// contains filtered or unexported fields
}
func Reporter ¶
func Reporter(c *Client, r metrics.Registry) *MetricsReporter
Create an un-started MetricsReporter. In most circumstances, the `metrics.DefaultRegistry` will suffice for the required `metrics.Registry`. The recreated `MetricsReporter` will not be started. Invoke `go r.Start(..)` with a `time.Duration` to enable reporting.
func (*MetricsReporter) Report ¶
func (mr *MetricsReporter) Report() error
POST a single series report to the Datadog API. A 200 or 202 is expected for this to complete without error.
func (*MetricsReporter) Series ¶
func (mr *MetricsReporter) Series() []*Series
For each metric assocaited with the current Registry, convert it to a `Series` message, and return them all as a single array. The series messages will have the current hostname of the `Client`.
func (*MetricsReporter) Start ¶
func (mr *MetricsReporter) Start(d time.Duration)
Start this reporter in a blocking fashion, pushing series data to datadog at the specified interval. If any errors occur, they will be logged to the default logger, and further updates will continue.
Scheduling is done with a `time.Ticker`, so non-overlapping intervals are absolute, not based on the finish time of the previous event. They are, however, serial.