Getting Started with Tracing
Datadog Application Performance Monitoring (APM or tracing) is used to collect traces from your backend application code. This beginners’ guide shows you how to get your first trace into Datadog.
Note: Datadog APM is available for many languages and frameworks. See the documentation on Instrumenting Your Application
If you haven’t already, create a Datadog account.
Before installing the Datadog Agent, set up a Vagrant Ubuntu 16.04 virtual machine using the following commands. For more information about Vagrant, see their Getting Started page.
vagrant init ubuntu/xenial64
To install the Datadog Agent on a host, use the one line install command updated with your Datadog API key:
DD_API_KEY=<DATADOG_API_KEY> DD_SITE="" bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script.sh)"
Verify the Agent is running with the status command:
sudo datadog-agent status
After a few minutes, verify the Agent is connected to your account by checking the Infrastructure List in Datadog.
Follow the in-app documentation (recommended)
For the remaining steps, follow the Quick start instructions within the Datadog site for the best experience, including:
- Step-by-step instructions scoped to your deployment configuration (in this case, a host-based deployment).
- Dynamically set
- Enable the Continuous Profiler, ingesting 100% of traces, and Trace ID injection into logs during setup.
For the latest versions of Agent v6 and v7, APM is enabled by default. You can see this in the Agent
datadog.yaml configuration file:
## Whether or not the APM Agent should run
# enabled: true
2019-03-25 20:33:18 INFO (run.go:136) - trace-agent running on host ubuntu-xenial
2019-03-25 20:33:18 INFO (api.go:144) - listening for traces at http://localhost:8126
2019-03-25 20:33:28 INFO (api.go:341) - no data received
2019-03-25 20:34:18 INFO (service.go:63) - total number of tracked services: 0
For the best experience, it is recommended to use the the environment variable
DD_ENV to configure
env through your service’s tracer.
Additionally, if your tracer has logs injection enabled then the
env is consistent across traces and logs. Read more about how this works in Unified Service Tagging.
Alternatively, name your environment by updating
datadog.yaml to set
apm_config. To learn more about setting
env for APM, see the setting primary tags to scope guide.
Before setting up the application, install
ddtrace on your Ubuntu VM:
sudo apt-get install python-pip
pip install flask
pip install ddtrace
On the Ubuntu VM, create the application
hello.py with the following content:
from flask import Flask
app = Flask(__name__)
return 'hello world'
if __name__ == '__main__':
ddtrace which automatically instruments your application in Datadog:
ddtrace-run python hello.py
You should see a similar output to:
* Serving Flask app "hello" (lazy loading)
* Running on http://0.0.0.0:5050/ (Press CTRL+C to quit)
Test your application and send your traces to Datadog using
curl. Your application should be running (as shown above). In a separate command prompt run:
After a few minutes, your trace displays in Datadog under the
hello service. Check the services page or trace list.
Additional helpful documentation, links, and articles: