Add the Datadog Tracing Library

Overview

To automatically instrument your application with Datadog libraries:

  1. Install and configure the Agent.
  2. Add the Datadog tracing library to your code.

Install and configure the Agent

Install and configure the Datadog Agent to receive traces from your instrumented application. By default, the Datadog Agent is configured to receive traces in your datadog.yaml file under apm_config with enabled: true and listens for trace data at http://localhost:8126.

For containerized environments, follow the links below to enable trace collection within the Datadog Agent.

Containers

  1. Set apm_non_local_traffic: true in the apm_config section of your main datadog.yaml configuration file.
  2. See the specific setup instructions to ensure that the Agent is configured to receive traces in a containerized environment:
Docker
Kubernetes
Amazon ECS
ECS Fargate

  1. The trace client attempts to send traces to the Unix domain socket /var/run/datadog/apm.socket by default. If the socket does not exist, traces are sent to http://localhost:8126.

    If a different socket, host, or port is required, use the DD_TRACE_AGENT_URL environment variable. For example:

    DD_TRACE_AGENT_URL=http://custom-hostname:1234
    DD_TRACE_AGENT_URL=unix:///var/run/datadog/apm.socket
    

    Similarly, the trace client attempts to send stats to the /var/run/datadog/dsd.socket Unix domain socket. If the socket does not exist, then stats are sent to http://localhost:8125.

  1. Set DD_SITE in the Datadog Agent to to ensure the Agent sends data to the right Datadog location.

AWS Lambda

To set up Datadog APM in AWS Lambda, see the Tracing Serverless Functions documentation.

Other environments

Tracing is available for several other environments, such as Heroku, Cloud Foundry, AWS Elastic Beanstalk, and Azure App Service.

For other environments, see the Integrations documentation for that environment and contact support if you are encountering any setup issues.

Instrument your application

Set up your application to send traces using one of the following official Datadog tracing libraries:

Java
Python
Ruby
go
Node.js
PHP
C++
.Net
.Net
Android
iOS

To instrument an application written in a language that does not have official library support, see the list of community tracing libraries.