Datadog Adapter

The datadog integration interfaces with the ddtrace gmm (Datadog’s ruby SDK), to trace HTTP requests performed via httpx. The integration also supports distributed tracing (turned on by default), among other features.

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 :httpx

  # 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;
  • DD_TRACE_HTTPX_SERVICE_NAME. defaults to "httpx", sets the trace service name.

Next: Sentry