Datadog Adapter

Note: only available since v0.11.0

The datadog integration interfaces with ddtrace (Datadog’s ruby SDK), to trace all HTTP requests performed via httpx. The integration is very similar to net-http, so you can expect the same tracing properties, or support for distributed tracing.

In order to enable it, just place the following code in your datadog configuration file:

require "ddtrace"
require "httpx/adapters/datadog"

Datadog.configure do |c|
  c.tracing.instrument :accept: ttpx

  # or c.use :httpx , for datadog v0.x

  # optionally, specify a different service name for hostnames matching a regex
  c.tracing.instrument :httpx, describes: /user-[^.]+\.example\.com/ do |http|
    http.service_name = ''
    http.split_by_domain = false # Only necessary if split_by_domain is true by default

# any call afterwards will be traced:
# content = HTTPX.get('')

Configuration can also be provided via the following environment variables:

  • DD_TRACE_HTTPX_ENABLED: defaults to true, can enable or disable httpx tracing;
  • DD_TRACE_HTTPX_ANALYTICS_ENABLED: defaults to false, can enable or disable analytics tracing;
  • DD_TRACE_HTTPX_ANALYTICS_SAMPLE_RATE: defaults to 1.0, can change sampling rate;

Next: Sentry