DatadogHttp

Module VersionHex DocsTotal DownloadLicenseLast Updated

A client for Datadog’s HTTP API, useful for building integrations.

This community library is not an official product or project of Datadog. Maintainers are not affiliated with Datadog in any way.

Supported endpoints

Installation

If available in Hex, the package can be installed by adding datadog_http to your list of dependencies in mix.exs:

def deps do
  [
    {:datadog_http, "~> 0.0.1"}
  ]
end

Configuration

All calls to Datadog require an API key. Add the following configuration to your project to set the values. This configuration is optional, see below for a runtime configuration. The library will raise an error if the relevant credentials are not provided either via config.exs or at runtime.

config :datadog_http,
  base_url: "https://api.datadoghq.com",
  api_key: "your_client_id",
  adapter: Tesla.Adapter.Hackney, # optional
  http_options: [timeout: 10_000, recv_timeout: 30_000] # optional

By default, base_url is set to the main datadog API endpoint (https://api.datadoghq.com).

Runtime configuration

Alternatively, you can provide the configuration at runtime. The configuration passed as a function argument will overwrite the configuration in config.exs, if one exists.

For example, if you want to hit a different URL when calling the metrics submission endpoint, you could pass in a configuration argument to DatadogHttp.Metrics.submit/2.

DatadogHttp.Metrics.submit(
  [],
  %{base_url: "https://api.datadoghq.eu", api_key: "an-api-key"}
)