3.5+ are supported. For a full list of supported libraries, visit the Compatibility Requirements page.
When you set up tracing, you’re also setting up Continuous Profiler, and you need only enable Profiler to start receiving profiling data from your app.
Installation and getting started
Follow the in-app documentation (recommended)
Follow the Quickstart instructions within the Datadog app for the best experience, including:
- Step-by-step instructions scoped to your deployment configuration (hosts, Docker, Kubernetes, or Amazon ECS).
- Dynamically set
- Enable the Continuous Profiler, ingesting 100% of traces, and Trace ID injection into logs during setup.
Otherwise, to begin tracing applications written in Python, install the Datadog Tracing library,
ddtrace, using pip:
Note: This command requires pip version
18.0.0 or greater. For Ubuntu, Debian, or another package manager, update your pip version with the following command:
pip install --upgrade pip
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
Configure the Datadog Agent for APM
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
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 the
apm_config section of 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:
After having instrumented your application, the tracing client sends traces to
localhost:8126 by 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:
from ddtrace import tracer
DD_SITE in the Datadog Agent to
to ensure the Agent sends data to the right Datadog location.
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. 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:
staging. Learn more about how to setup your environment. Available in version 0.38+.
- 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 (for example, see these Django docs). Available in version 0.38+.
- Define service name mappings to allow renaming services in traces, for example:
postgres:postgresql,defaultdb:postgresql. Available in version 0.47+.
- Set the application’s version, for example:
2020.02.13. Available in version 0.38+.
- A list of default tags to be added to every span and profile, for example:
layer:api,team:intake. Available in version 0.38+.
Enable web framework and library instrumentation. When
false, the application code doesn’t generate any traces.
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. If set, this takes priority over hostname and port. Supports Unix Domain Sockets (UDS) in combination with the
apm_config.receiver_socket configuration in your
datadog.yaml file or the
DD_APM_RECEIVER_SOCKET environment variable set on the Datadog Agent. For example,
DD_TRACE_AGENT_URL=http://localhost:8126 for HTTP URL and
DD_TRACE_AGENT_URL=unix:///var/run/datadog/apm.socket for UDS.
- The URL used to connect to the Datadog Agent for DogStatsD metrics. If set, this takes priority over hostname and port. Supports Unix Domain Sockets (UDS) in combination with the
dogstatsd_socket configuration in your
datadog.yaml file or the
DD_DOGSTATSD_SOCKET environment variable set on the Datadog Agent. For example,
DD_DOGSTATSD_URL=udp://localhost:8126 for UDP URL and
DD_DOGSTATSD_URL=unix:///var/run/datadog/dsd.socket for UDS.
Override the address of the trace Agent host that the default tracer attempts to submit DogStatsD metrics to. Use
DD_AGENT_HOST to override
Override the port that the default tracer submits DogStatsD metrics to.
Enable connecting logs and trace injection.
Additional helpful documentation, links, and articles: