Documentation
¶
Index ¶
- Constants
- type APIClient
- type AlertType
- type DDApiResponse
- type DDClient
- type DDEvent
- type DDMetric
- type DDMetricSeries
- type DDServiceCheck
- type HTTPClient
- type Priority
- type Stats
- func (c *Stats) Close()
- func (c *Stats) Count(name string, value float64, tags []string)
- func (c *Stats) Decrement(name string, tags []string)
- func (c *Stats) ErrorCallback(f func(err error))
- func (c *Stats) Errors() []error
- func (c *Stats) Event(event *DDEvent) error
- func (c *Stats) Flush()
- func (c *Stats) FlushCallback(f func(metrics map[string]*metric))
- func (c *Stats) Gauge(name string, value float64, tags []string)
- func (c *Stats) Increment(name string, tags []string)
- func (c *Stats) SendSeries(series []*DDMetric) error
- func (c *Stats) ServiceCheck(check, message string, status Status, tags []string) error
- type Status
Constants ¶
const ( Okay = iota Warning Critical Unknown )
DDServiceCheck Status values
const ( AlertError = AlertType("error") AlertWarning = AlertType("warning") AlertInfo = AlertType("info") AlertSuccess = AlertType("success") )
DDEvent AlertType values
const ( PriorityNormal = Priority("normal") PriorityLow = Priority("low") )
DDEvent Priority values
const ( DefaultWorkerCount = 10 DefaultWorkerBuffer = 100 DefaultFlushInterval = time.Second * 60 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIClient ¶
type APIClient interface { SendSeries(*DDMetricSeries) error SendServiceCheck(*DDServiceCheck) error SendEvent(*DDEvent) error SetHTTPClient(HTTPClient) }
type DDApiResponse ¶
type DDApiResponse struct {
Errors []string `json:"errors"`
}
type DDClient ¶
type DDClient struct {
// contains filtered or unexported fields
}
func NewDDClient ¶
func (*DDClient) SendSeries ¶
func (c *DDClient) SendSeries(series *DDMetricSeries) error
func (*DDClient) SendServiceCheck ¶
func (c *DDClient) SendServiceCheck(check *DDServiceCheck) error
func (*DDClient) SetHTTPClient ¶
func (c *DDClient) SetHTTPClient(client HTTPClient)
type DDEvent ¶
type DDEvent struct { AggregationKey string `json:"aggregation_key"` AlertType AlertType `json:"alert_type"` DateHappened int64 `json:"date_happened"` DeviceName string `json:"device_name"` Host string `json:"host"` Priority Priority `json:"priority"` RelatedEventID int64 `json:"related_event_id"` SourceTypeName string `json:"source_type_name"` Tags []string `json:"tags"` Title string `json:"title"` }
type DDMetricSeries ¶
type DDMetricSeries struct {
Series []*DDMetric `json:"series"`
}
type DDServiceCheck ¶
type HTTPClient ¶
type Stats ¶
type Stats struct {
// contains filtered or unexported fields
}
func (*Stats) Close ¶
func (c *Stats) Close()
Close signals a shutdown, and blocks while waiting for a final flush, and all workers to shutdown.
func (*Stats) Count ¶
Count creates or adds a count metric by value. This is a non-blocking method, if the channel buffer is full, then the metric not recorded. Count stats are sent as rate, by taking the count value and dividing by the number of seconds since the last flush.
func (*Stats) Decrement ¶
Decrement creates or subtracts a count metric by -1. This is a non-blocking method, if the channel buffer is full, then the metric not recorded. Count stats are sent as rate, by taking the count value and dividing by the number of seconds since the last flush.
func (*Stats) ErrorCallback ¶
ErrorCallback registers a call back function that will be called if any error is returned by the api client during a flush.
func (*Stats) Errors ¶
Errors returns a slice of all errors returned by the api client during a flush.
func (*Stats) Event ¶
Event immediately posts an DDEvent to he Datadog api. If host, or namespace vales are missing, the values will be filled before sending to the api. Global tags are appended to the event.
func (*Stats) Flush ¶
func (c *Stats) Flush()
Flush signals the main worker thread to copy all current metrics, and send them to the Datadog api.
func (*Stats) FlushCallback ¶
FlushCallback registers a call back function that will be called at the end of every successful flush.
func (*Stats) Gauge ¶
Gauge creates or updates a gauge metric by value. This is a non-blocking method, if the channel buffer is full, then the metric not recorded. Gauge stats are reported as the last value sent before flush is called.
func (*Stats) Increment ¶
Increment creates or increments a count metric by +1. This is a non-blocking method, if the channel buffer is full, then the metric not recorded. Count stats are sent as rate, by taking the count value and dividing by the number of seconds since the last flush.
func (*Stats) SendSeries ¶
SendSeries immediately posts an DDMetric series to the Datadog api. Each metric in the series is checked for an host name, and the correct namespace. If host, or namespace vales are missing, the values will be filled before sending to the api. Global tags are added to all metrics.
func (*Stats) ServiceCheck ¶
ServiceCheck immediately posts an DDServiceCheck to he Datadog api. The namespace is prepended to the check name, if it is missing. Host, and time is automatically added. Global tags are appended to tags passed to the method.