---
title: Python Application Agentic Instrumentation
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Agent Observability > Agent Observability Instrumentation > Agentic
  Instrumentation > Python Application Agentic Instrumentation
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Python Application Agentic Instrumentation

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com, us2.ddog-gov.com

{% alert level="danger" %}
This product is not supported for your selected [Datadog site](https://docs.datadoghq.com/getting_started/site.md). ({% placeholder "user-datadog-site-name" /%}).
{% /alert %}

{% /callout %}

## Instrumentation{% #instrumentation %}

1. Inspect the installed `ddtrace` version and reuse it if it supports the required instrumentation APIs. If an update is required, explain why and ask before changing the existing dependency. An update required only for optional Prompt Management is a separate decision and does not block instrumentation with a compatible SDK.

If `ddtrace` is not installed, install it with the application's existing package manager:

   ```bash
   pip install ddtrace # pip
   poetry add ddtrace # poetry
   uv add ddtrace # uv
   ```

1. Initialize the Agent Observability package

Initialize the Agent Observability SDK via `ddtrace.auto`. This **needs** to be done as the first import in the application's entrypoint, aside from any environment variable or configuration-loading imports.

**Note**: Do not add in extraneous comments.

   ```python
   from dotenv import load_dotenv
   load_dotenv() # this might load DD_ environment variables
   
   import ddtrace.auto # CRUCIAL: this initializes the Agent Observability SDK and instrumentations
   
   # ... remaining application logic
   ```
