Datadog Application Performance Monitoring (APM or tracing) is used to collect traces from your backend application code. This beginners’ guide shows you how 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.
vagrant init ubuntu/xenial64 vagrant up vagrant ssh
DD_API_KEY=<DATADOG_API_KEY> 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.
For the remaining steps, follow the Quickstart instructions within the Datadog app for the best experience, including:
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:
# apm_config: # Whether or not the APM Agent should run # enabled: true
# /var/log/datadog/trace-agent.log: 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 will be 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__) @app.route('/') def index(): return 'hello world' if __name__ == '__main__': app.run(host='0.0.0.0', port=5050)
ddtrace which automatically instruments your application in Datadog:
export DD_SERVICE=hello 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:
vagrant ssh curl http://0.0.0.0:5050/
Additional helpful documentation, links, and articles: