Application Instrumentation

Overview

Application Instrumentation is the process of adding code to your application to capture and report observability data to Datadog, such as traces, metrics, and logs.Glossary with Datadog APM involves:

  1. SDK setup: Adding a Datadog SDK to your application.

  2. Span creation: Capturing observability data as A span is a logical unit of work in a distributed system for a given period.Glossarys.

    Spans are automatically generated by default as soon as the SDK is loaded. This is known as auto-instrumentation and provides sufficient visibility for most users. If you need more control, you can optionally add custom spans.

Note: These steps assume you have a Datadog Agent installed and configured to receive traces.

The APM pipeline

Getting started

Prefer vendor-neutral instrumentation? See the OpenTelemetry documentation for using OpenTelemetry with Datadog.

Single Step Instrumentation (SSI) automatically installs and configures Datadog SDKs with a single command. Auto-instrumentation then immediately begins capturing traces from your supported frameworks and libraries, with no code changes required.


Manual setup and custom spans

As your observability needs grow, you can add more control and customization:

For full SDK configuration control: Use manually managed Datadog SDKs if you need granular control over SDK behavior and configuration.


For custom spans without code changes: Use Dynamic Instrumentation to create custom spans from the Datadog UI without redeploying your application.


For custom spans in code: Add code-based custom instrumentation to instrument custom business logic or add application-specific metadata to spans.


These options can be combined. For example, you can start with Single Step Instrumentation and add code-based custom instrumentation for specific spans, or use manually managed SDKs with Dynamic Instrumentation for no-deploy span additions.

Detailed comparison

SDK setup

Single Step Instrumentation is the recommended starting point for most users. If you need more control over SDK configuration, you can use manually managed SDKs instead:

Single Step Instrumentation (recommended)Manually managed SDKs
How it worksDatadog automatically installs and loads SDKs into your application processes, at runtime, with a single command.You install and configure SDKs directly in your application code or build process.
Code changes?NoYes
Setup complexityLow - minimal configuration neededMedium - requires environment and build configuration
Configuration controlStandard defaults with optional overridesFull control through environment variables and code
When to useStart here for fast, consistent instrumentation across services without code changes.Progress to this when you need granular control over SDK behavior and configuration.

Span customization

Auto-instrumentation automatically creates spans for supported frameworks and libraries, providing essential observability with no additional work. When you need visibility into custom code paths or want to enrich traces with application-specific data, you can add custom spans using either Dynamic Instrumentation or code-based custom instrumentation:

Dynamic InstrumentationCode-based custom instrumentation
How it worksConfigure instrumentation rules in the Datadog UI; rules are applied at runtime.Add explicit tracing API calls in your application code.
Code changes?NoYes
Deployment requiredNoYes (to add or modify spans)
When to useAdd custom spans without code changes or redeployments.Progress to this when you need complex instrumentation logic or want spans permanently defined in code.

APM setup tutorials

The following tutorials guide you through setting up distributed tracing for a sample application on various infrastructure scenarios, with both automatic and custom instrumentation:


Further reading