3.5+ are supported. For a full list of supported libraries, visit the Compatibility Requirements page.
Follow the Quickstart instructions within the Datadog app for the best experience, including:
Otherwise, to begin tracing applications written in Python, install the Datadog Tracing library,
ddtrace, using pip:
pip install ddtrace
Then to instrument your Python application use the included
ddtrace-run command. To use it, prefix your Python entry-point command with
For example, if your application is started with
python app.py then:
ddtrace-run python app.py
Install and configure the Datadog Agent to receive traces from your now instrumented application. By default the Datadog Agent is enabled in your
datadog.yaml file under
apm_enabled: true and listens for trace traffic at
localhost:8126. For containerized environments, follow the links below to enable trace collection within the Datadog Agent.
apm_non_local_traffic: true in your main
datadog.yaml configuration file
See the specific setup instructions to ensure that the Agent is configured to receive traces in a containerized environment:
localhost:8126by default. If this is not the correct host and port change it by setting the below env variables:
You can also set the hostname and port in code:
import os from ddtrace import tracer tracer.configure( hostname="custom-hostname", port="1234", )
To set up Datadog APM in AWS Lambda, see the Tracing Serverless Functions documentation.
For more advanced usage, configuration, and fine-grain control, see Datadog’s API documentation.
When using ddtrace-run, the following environment variable options can be used:
|Enable debug logging in the tracer.|
|Override the modules patched for this application execution. It should follow the format: |
It is recommended to use
DD_VERSION to set
version for your services. Refer to the Unified Service Tagging documentation for recommendations on how to configure these environment variables.
|Set the application’s environment, for example: |
|The service name to be used for this application. The value is passed through when setting up middleware for web framework integrations like Pylons, Flask, or Django. For tracing without a web integration, it is recommended that you set the service name in code. Available in version 0.38+.|
|Set the application’s version, for example: |
|A list of default tags to be added to every span, profile, and runtime metric, for example: |
|Enable web framework and library instrumentation. When |
|Override the address of the trace Agent host that the default tracer attempts to submit traces to.|
|Override the port that the default tracer submit traces to.|
|The URL of the Trace Agent that the tracer submits to. Takes priority over hostname and port, if set. Supports Unix Domain Sockets in combination with the |
|Enable Priority Sampling.|
|Enable connecting logs and trace injection.|
Additional helpful documentation, links, and articles: