datadog

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// MaxRetries is how many times Do retries a request that Datadog rate limits.
	MaxRetries = 5
	// DefaultRetryWait is used when a 429 carries no X-RateLimit-Reset header.
	DefaultRetryWait = 10 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client handles communication with the Datadog REST API

func NewClient

func NewClient(httpClient *http.Client, baseURL, apiKey, appKey string) *Client

NewClient creates new Datadog API client for baseURL, the API host of the caller's Datadog site, e.g. https://api.datadoghq.com, with an API key and an application key. Accepts custom *http.Client, uses a copy of DefaultClient if nil. The client is copied, and the copy does not follow redirects: Go sends custom headers such as DD-API-KEY on to the redirect target, even on another host, and the Datadog API does not redirect. A redirect comes back as an error instead.

func (*Client) Do

func (c *Client) Do(request *http.Request, responseTarget any) error

Do executes an API request and unmarshals the response body into responseTarget. A 429 is retried up to MaxRetries times, after the X-RateLimit-Reset seconds. A request the http.Client times out returns an error that wraps errors.ErrTimeout and leaves out the URL, which can carry a long query.

func (*Client) ListActiveMetrics

func (c *Client) ListActiveMetrics(ctx context.Context, from time.Time) ([]string, error)

ListActiveMetrics lists the metrics that reported since from.

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, method, path string, body any) (*http.Request, error)

NewRequest creates an API request A relative path can be provided, e.g. "/api/v1/query?from=..."

func (*Client) Query

func (c *Client) Query(ctx context.Context, queries []string, from, to time.Time) ([][]Point, error)

Query runs the queries as one /api/v1/query call, so a batch costs one request against the metrics rate limit. The result has the points of each query, in order. A query with no data in the window gets none, and the null points Datadog pads a batch onto one time grid with are dropped.

type Point

type Point struct {
	T time.Time
	V float64
}

Point is one timeseries point.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL