Datadog Exporter Example

These examples show how to use OpenTelemetry to send tracing data to Datadog.

Basic Example

  • Installation

pip install opentelemetry-api
pip install opentelemetry-sdk
pip install opentelemetry-ext-datadog
  • Start Datadog Agent

docker run --rm \
    -v /var/run/docker.sock:/var/run/docker.sock:ro \
    -v /proc/:/host/proc/:ro \
    -v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro \
    -p 127.0.0.1:8126:8126/tcp \
    -e DD_API_KEY="<DATADOG_API_KEY>" \
    -e DD_APM_ENABLED=true \
    datadog/agent:latest
  • Run example

python datadog_exporter.py

Auto-Instrumention Example

  • Installation

pip install opentelemetry-api
pip install opentelemetry-sdk
pip install opentelemetry-ext-datadog
pip install opentelemetry-instrumentation
pip install opentelemetry-ext-flask
pip install flask
pip install requests
  • Start Datadog Agent

docker run --rm \
    -v /var/run/docker.sock:/var/run/docker.sock:ro \
    -v /proc/:/host/proc/:ro \
    -v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro \
    -p 127.0.0.1:8126:8126/tcp \
    -e DD_API_KEY="<DATADOG_API_KEY>" \
    -e DD_APM_ENABLED=true \
    datadog/agent:latest
  • Start server

opentelemetry-instrument python server.py
  • Run client

opentelemetry-instrument python client.py testing
  • Run client with parameter to raise error

opentelemetry-instrument python client.py error