APM & Distributed Tracing Fundamentals Certification / 02 / 04

Application Instrumentation

What this domain covers

In this domain you learn the flow from embedding the Datadog SDK (tracing library) in an application to spans reaching Datadog through the Agent. There are six pillars: the paths for installing the SDK (Single Step Instrumentation and manually managed SDKs) and the default destination; how to choose among instrumentation types (automatic instrumentation, custom instrumentation in code, and Dynamic Instrumentation); the role the trace-agent plays inside the Agent; the difference between sampling (ingestion) and retention; at which layer sensitive data is obfuscated; and the fact that the profiler ships with the SDK and works simply by being enabled. The exam asks questions of the form "which instrumentation method fits this requirement" and "which layer does this setting affect". Numbers and default values are based on the official documentation as of September 2026.

Topics listed in the official guide

  • Datadog Tracing Libraries
  • Instrumentation Types
  • Datadog Agent Architecture
  • Sampling vs Retention
  • APM Data Security
  • Profile Collection

Key points

  • By default the SDK first sends to the Unix domain socket /var/run/datadog/apm.socket, and if it is not present, to localhost:8126.
  • With SSI the Agent loads the SDK into supported processes at runtime. No code changes are needed, but it is automatically disabled when custom instrumentation code is detected.
  • There are two APIs for custom instrumentation in code: the OpenTelemetry API (recommended) and the Datadog API. OpenTracing is archived and unsupported.
  • Dynamic Instrumentation adds spans and more from the UI. No deployment is needed, but it requires Agent 7.49.0 or later and Remote Configuration.
  • The trace-agent is an optional process separate from the main Agent process and is enabled by default. On Windows it appears as a separate service named datadog-trace-agent.
  • For an Agent running in a container to receive application traces, set apm_non_local_traffic in apm_config to true.
  • Head-based sampling decides keep or drop when the root span starts and propagates the decision downstream, so a trace is kept or dropped as a whole. The Agent's default target is 10 traces per second.
  • Retention filters are the mechanism that selects which spans are retained for 15 days after ingestion; they do not affect how much the Agent sends. Ingestion volume is controlled with Ingestion Controls.
  • The Agent obfuscates SQL literals in resource names and credit card numbers by default. Removing the query string from HTTP URLs and removing stack traces are disabled by default.
  • Continuous Profiler ships with the Datadog SDK, so if APM is already installed it works simply by enabling it with DD_PROFILING_ENABLED=true.

Terms and concepts

The four paths to instrumentation

The official documentation divides instrumentation into two stages: installing the SDK and creating spans. Installing the SDK is done either with Single Step Instrumentation (recommended, no code changes, standard defaults with optional overrides) or with a manually managed SDK (embedded in the code or the build, full control through environment variables and code). Adding spans is done either with Dynamic Instrumentation (rules defined in the UI, no deployment needed) or with custom instrumentation in code (writing API calls, a deployment is needed for changes). The two can be combined, so a setup that starts with SSI and defines only specific spans in code is also possible.

Single Step Instrumentation and the injector

With SSI, when you enable APM Instrumentation while installing the Agent, the injector (a shared library) enters the application's process, detects the runtime, and sets the environment variables and arguments that load the SDK. On Linux this uses LD_PRELOAD, on Kubernetes the Admission Controller rewrites the Pod spec, and on Windows a kernel driver loads a DLL. The injector finishes its work before the application's main and runs before the SDK reads its environment variables, so it cannot be stopped with DD_TRACE_ENABLED=false.

SDK destination and Agent receiving settings

By default the Agent has apm_config set to enabled: true and listens for traces on localhost:8126. By default the SDK first tries to send to the Unix domain socket /var/run/datadog/apm.socket, and if it is not present, sends to localhost:8126. A different destination is specified with DD_TRACE_AGENT_URL. When the Agent runs in a container, apm_non_local_traffic: true is required. The SDK configuration currently in effect can be checked on the SDK Configuration tab of Service Config.

The three APIs for custom instrumentation in code

To observe in-house code or complex functions that automatic instrumentation does not capture, you embed tracing code directly in the application. There are three APIs. The first is the OpenTelemetry API; the Datadog SDK provides its implementation, so you can keep vendor-neutral instrumentation while using Datadog's native features (recommended). The second is the Datadog API, which lets you create spans, remove unwanted spans, and add span tags programmatically. The third is OpenTracing; it can still send data, but the project itself is archived and unsupported, so it is not chosen for new work.

Dynamic Instrumentation

A feature that adds metrics, spans, and span tags to a running production system without a restart or code changes. Supported languages are Java, Python, .NET, and PHP. The prerequisites are Agent 7.49.0 or later, Remote Configuration enabled on that Agent, a supported SDK, and Unified Service Tags. Dynamic spans emit a span for each method execution, and exceptions are recorded in the error tag. Dynamic span tags can be attached to the active span or the service entry span, and a condition can be written. It cannot be used on Azure App Services or in serverless environments.

Agent architecture and the trace-agent

In addition to the main process that collects metrics and logs (the Collector and the Forwarder), Agent 6 and 7 have two optional processes enabled in datadog.yaml. The APM Agent (trace-agent), which collects traces, is enabled by default, and the Process Agent by default collects containers only. On Windows they appear as three separate services. Besides receiving traces, the trace-agent is responsible for distributing sampling rates to the SDKs, picking up error traces and rare traces dropped by head-based sampling, and obfuscating resource names and tags.

The difference between sampling (ingestion) and retention

Ingestion is the decision of which spans are sent to Datadog, and it is handled by the SDK and the Agent. The default is head-based sampling, in which the Agent distributes rates to the SDKs to target 10 traces per second overall, and DD_TRACE_SAMPLING_RULES on the SDK side takes precedence over the Agent's rate. The Agent's error sampler and rare trace sampler complement this. Retention is the step after ingestion that selects which spans are indexed for 15 days; it is handled by retention filters and does not affect ingestion volume.

APM data security

Traces can contain personal information such as names, email addresses, credit card numbers, and database statements. The countermeasures form three layers: obfuscating in the Agent at collection time, controlling in the SDK at collection time, and processing with Sensitive Data Scanner at ingestion time. The Agent replaces SQL numeric literals and bind variables in resource names with ?. Obfuscation for MongoDB, Redis, and others and credit card number detection are enabled by default, while removing the query string from HTTP URLs and removing stack traces are disabled by default. Health checks can be excluded with ignore_resources.

Profile collection

Because the profiler ships with the Datadog SDK, an application that already collects traces with APM needs no additional library and works simply by enabling it. Agent v6 or later is required, and if APM is not enabled you set DD_APM_ENABLED=true on the Agent side and open port 8126/TCP. On the application side you set DD_PROFILING_ENABLED=true along with service, env, and version, and the profiles appear on the Profiler page after a few minutes. In Java there are CPU, Wallclock, Allocations, and other profile types, and serverless is out of scope.

Check your understanding

Check what you have learned with 5 questions