# enable_auto_tracing

> **Function** in `langchain_azure_ai`

📖 [View in docs](https://reference.langchain.com/python/langchain-azure-ai/callbacks/tracers/auto_instrument/enable_auto_tracing)

Enable auto-injection of Azure tracer into callback managers.

When called, every new ``BaseCallbackManager`` instance and every callback
manager created through LangGraph's helper factories will automatically
include an ``AzureAIOpenTelemetryTracer`` in its inheritable handlers.

Each parameter falls back to an environment variable when not supplied:

* *connection_string* ← ``APPLICATION_INSIGHTS_CONNECTION_STRING``
* *enable_content_recording* ← ``AZURE_TRACING_GEN_AI_CONTENT_RECORDING_ENABLED``
* *project_endpoint* ← ``AZURE_AI_PROJECT_ENDPOINT`` (or
  ``FOUNDRY_PROJECT_ENDPOINT`` when the former is not set)
* *provider_name* ← ``AZURE_TRACING_PROVIDER_NAME``
* *agent_id* ← ``AZURE_TRACING_AGENT_ID``
* *trace_all_langgraph_nodes* ← ``AZURE_TRACING_ALL_LANGGRAPH_NODES``
* *message_keys* ← ``OTEL_MESSAGE_KEYS`` (comma-separated)
* *message_paths* ← ``OTEL_MESSAGE_PATHS`` (comma-separated)
* *auto_configure_azure_monitor* ← ``OTEL_AUTO_CONFIGURE_AZURE_MONITOR``
* *trace_state* ← ``OTEL_TRACE_LANGGRAPH_STATE``
* *max_state_size* ← ``OTEL_MAX_STATE_SIZE``

## Signature

```python
enable_auto_tracing(
    *,
    connection_string: str | None = None,
    enable_content_recording: bool | None = None,
    project_endpoint: str | None = None,
    credential: Any | None = None,
    provider_name: str | None = None,
    agent_id: str | None = None,
    trace_all_langgraph_nodes: bool | None = None,
    message_keys: list[str] | tuple[str, ...] | None = None,
    message_paths: list[str] | tuple[str, ...] | None = None,
    auto_configure_azure_monitor: bool | None = None,
    trace_state: bool | None = None,
    max_state_size: int | None = None,
    tracer: AzureAIOpenTelemetryTracer | None = None,
) -> None
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `connection_string` | `str \| None` | No | Application Insights connection string. (default: `None`) |
| `enable_content_recording` | `bool \| None` | No | Whether to capture message/content payloads (default ``False``). (default: `None`) |
| `project_endpoint` | `str \| None` | No | Azure AI project endpoint for connection string resolution. (default: `None`) |
| `credential` | `Any \| None` | No | Azure credential used with project endpoint resolution. (default: `None`) |
| `provider_name` | `str \| None` | No | Default provider name for emitted GenAI spans (default ``"azure.ai.openai"``). (default: `None`) |
| `agent_id` | `str \| None` | No | Default agent identifier for emitted spans. (default: `None`) |
| `trace_all_langgraph_nodes` | `bool \| None` | No | Whether to trace all LangGraph nodes (default ``True``). (default: `None`) |
| `message_keys` | `list[str] \| tuple[str, ...] \| None` | No | State keys that hold messages (default ``["messages"]``). (default: `None`) |
| `message_paths` | `list[str] \| tuple[str, ...] \| None` | No | Dotted paths for nested message locations. (default: `None`) |
| `auto_configure_azure_monitor` | `bool \| None` | No | Set to ``True`` to enable automatic Azure Monitor configuration (default ``False``; hosted agents configure their own ``TracerProvider``). In non-hosted usage, leaving this as ``False`` means Azure Monitor is not configured automatically, so spans may not export unless your application configures a ``TracerProvider`` and exporter separately. (default: `None`) |
| `trace_state` | `bool \| None` | No | Whether to capture the full LangGraph state on each agent node span (default ``False``). (default: `None`) |
| `max_state_size` | `int \| None` | No | Maximum character length for serialized state (default ``32768``). (default: `None`) |
| `tracer` | `AzureAIOpenTelemetryTracer \| None` | No | Pre-built tracer to inject directly.  When supplied, all other configuration arguments are ignored. (default: `None`) |

---

[View source on GitHub](https://github.com/langchain-ai/langchain-azure/blob/7a6a664d617264df8dcb12fcfb1bacc09f21d504/libs/azure-ai/langchain_azure_ai/callbacks/tracers/auto_instrument.py#L291)