Skip to main content
This guide explains how to use Datadog with your Pipecat Cloud agents for logging, traces, and custom metrics.
This guide is a work in progress and may have some sharp edges. However, it has been vetted for basic usage.

Prerequisites

  • Have a Datadog account and API key.
  • Use at least version 0.0.7 of the Pipecat Cloud base image:

Add Datadog API key as a secret

If you’re using keeping your secrets in an .env file as recommended, add your Datadog API key to that file:
Then update your secret set from that file:
See Secrets for more details.

Create datadog.yaml

This file contains the Datadog Agent configuration. The configuration shown below assumes you want all Datadog features covered in this guide (logging, traces, and custom metrics).

Create pre-app.sh

This script runs before the agent launcher runs. The file shown below assumes you want all Datadog features covered in this guide (logging, traces, and custom metrics).
You may see Starting Datadog Agent: datadog-agent failed! in your logs, triggered by service datadog-agent start. You can safely ignore this! As long as service datadog-agent status and service datadog-agent-trace status indicate that both of those services end up running, then we should have no trouble sending logs, traces, and custom metrics to Datadog.

Update Dockerfile with the Datadog Agent

The snippet shown below assumes you want all Datadog features covered in this guide (logging, traces, and custom metrics).

Enabling logging

Enable logging in datadog.yaml

Ensure the following is present in your datadog.yaml:

Create python.d/conf.yaml

Configure log collection for your agent:

Update Dockerfile for logging

Ensure the following is present in your Dockerfile:
This configures the Datadog Agent to collect logs from your agent.

Configure logger in bot.py

Add a Datadog sink to your logger. This sink will write log lines into a file that your Datadog Agent will read from, in a Datadog-friendly format.

Enabling traces

Enable traces in datadog.yaml

Ensure apm_config.enabled is NOT set to false in your datadog.yaml:

Start the Datadog Trace Agent in pre-app.sh

Ensure the following is present in your pre-app.sh:

Prepare file system in Dockerfile

Ensure the following is present in your Dockerfile:

Add ddtrace Python library

In your requirements.txt:

Record traces in bot.py

Enabling custom metrics

Enable custom metrics in datadog.yaml

Ensure use_dogstatsd is NOT set to false in your datadog.yaml:

Prepare file system in Dockerfile

Ensure the following is present in your Dockerfile:

Add datadog Python library

In your requirements.txt:

Record custom metrics in bot.py