dd-trace-go icon indicating copy to clipboard operation
dd-trace-go copied to clipboard

all: implement shared agent discovery

Open nsrip-dd opened this issue 3 years ago • 0 comments

dd-trace-go has lots of duplicated logic around agent discovery, including finding the agent URL, handling UDS, and detecting agent features. Move this logic into a shared package.

The shared discovery supports resolving the agent address from user config as follows:

  • First, in-code config (tracer.WithAgentAddr, profiler.WithAgentAddr, etc.)
  • If no in-code config, the value of DD_TRACE_AGENT_URL
  • Next, a combination of DD_AGENT_HOST and DD_TRACE_AGENT_PORT, defaulting to localhost and 8126, respectively
  • If none of those env vars are set, /var/run/datadog/apm.socket if it exists
  • Finally, localhost:8126

This is accomplished by adding functions to give an HTTP client (which handles UDS) and the address of the agent. The profiler and tracer can use these values first and then override them with user-provided options.

Note that this PR duplicates some of the work in #1199. We can resolve that one first and I can rebase this PR, or we can use this PR instead, either way works for me.

Resolves #1023

nsrip-dd avatar Aug 15 '22 13:08 nsrip-dd