Skip to content

Commit a17b72d

Browse files
Agent Framework update to observability docs (#750)
* update to observability docs * updated note tags
1 parent 51e95a0 commit a17b72d

1 file changed

Lines changed: 29 additions & 7 deletions

File tree

agent-framework/tutorials/agents/enable-observability.md

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,16 @@ The following OpenTelemetry packages are included by default:
150150
```text
151151
opentelemetry-api
152152
opentelemetry-sdk
153-
azure-monitor-opentelemetry
154-
azure-monitor-opentelemetry-exporter
155153
opentelemetry-exporter-otlp-proto-grpc
156154
opentelemetry-semantic-conventions-ai
157155
```
158156

157+
If you want to export to Azure Monitor (Application Insights), you also need to install the `azure-monitor-opentelemetry` package:
158+
159+
```bash
160+
pip install azure-monitor-opentelemetry
161+
```
162+
159163
## Enable OpenTelemetry in your app
160164

161165
Agent Frameworkagent framework provides a convenient `setup_observability` function that configures OpenTelemetry with sensible defaults.
@@ -179,12 +183,15 @@ The `setup_observability` function accepts the following parameters to customize
179183

180184
- **`otlp_endpoint`** (str, optional): The OTLP endpoint URL for exporting telemetry data. Default is `None`. Commonly set to `http://localhost:4317`. This creates an OTLPExporter for spans, metrics, and logs. Can be used with any OTLP-compliant endpoint such as [OpenTelemetry Collector](https://opentelemetry.io/docs/collector/), [Aspire Dashboard](/dotnet/aspire/fundamentals/dashboard/overview?tabs=bash), or other OTLP endpoints. Can also be set via `OTLP_ENDPOINT` environment variable.
181185

182-
- **`applicationinsights_connection_string`** (str, optional): Azure Application Insights connection string for exporting to Azure Monitor. Default is `None`. Creates AzureMonitorTraceExporter, AzureMonitorMetricExporter, and AzureMonitorLogExporter. You can find this connection string in the Azure portal under the "Overview" section of your Application Insights resource. Can also be set via `APPLICATIONINSIGHTS_CONNECTION_STRING` environment variable.
186+
- **`applicationinsights_connection_string`** (str, optional): Azure Application Insights connection string for exporting to Azure Monitor. Default is `None`. Creates AzureMonitorTraceExporter, AzureMonitorMetricExporter, and AzureMonitorLogExporter. You can find this connection string in the Azure portal under the "Overview" section of your Application Insights resource. Can also be set via `APPLICATIONINSIGHTS_CONNECTION_STRING` environment variable. Requires installation of the `azure-monitor-opentelemetry` package.
183187

184188
- **`vs_code_extension_port`** (int, optional): Port number for the AI Toolkit or Azure AI Foundry VS Code extension. Default is `4317`. Allows integration with VS Code extensions for local development and debugging. Can also be set via `VS_CODE_EXTENSION_PORT` environment variable.
185189

186190
- **`exporters`** (list, optional): Custom list of OpenTelemetry exporters for advanced scenarios. Default is `None`. Allows you to provide your own configured exporters when the standard options don't meet your needs.
187191

192+
> [!IMPORTANT]
193+
> When no exporters (either through parameters or environment variables or as explicit exporters) are provided, the console exporter is configured by default for local debugging.
194+
188195
### Setup options
189196

190197
You can configure observability in three ways:
@@ -207,6 +214,7 @@ setup_observability() # Reads from environment variables
207214
```python
208215
from agent_framework.observability import setup_observability
209216

217+
# note that ENABLE_OTEL is implied to be True when calling setup_observability programmatically
210218
setup_observability(
211219
enable_sensitive_data=True,
212220
otlp_endpoint="http://localhost:4317",
@@ -327,22 +335,37 @@ The following metrics are also collected:
327335

328336
## Azure AI Foundry integration
329337

330-
If you're using Azure AI Foundry, there's a convenient method for automatic setup:
338+
If you're using Azure AI Foundry clients, there's a convenient method for automatic setup:
331339

332340
```python
333341
from agent_framework.azure import AzureAIAgentClient
334342
from azure.identity import AzureCliCredential
335343

336344
agent_client = AzureAIAgentClient(
337345
credential=AzureCliCredential(),
338-
project_endpoint="https://<your-project>.foundry.azure.com"
346+
# endpoint and model_deployment_name can be taken from environment variables
347+
# project_endpoint="https://<your-project>.foundry.azure.com"
348+
# model_deployment_name="<your-deployment-name>"
339349
)
340350

341351
# Automatically configures observability with Application Insights
342352
await agent_client.setup_azure_ai_observability()
343353
```
344354

345-
This method retrieves the Application Insights connection string from your Azure AI Foundry project and calls `setup_observability` automatically.
355+
This method retrieves the Application Insights connection string from your Azure AI Foundry project and calls `setup_observability` automatically. If you want to use Foundry Telemetry with other types of agents, you can do the same thing with:
356+
```python
357+
from agent_framework.observability import setup_observability
358+
from azure.ai.projects import AIProjectClient
359+
from azure.identity import AzureCliCredential
360+
361+
project_client = AIProjectClient(endpoint, credential=AzureCliCredential())
362+
conn_string = project_client.telemetry.get_application_insights_connection_string()
363+
setup_observability(applicationinsights_connection_string=conn_string)
364+
```
365+
Also see the [relevant Foundry documentation](/azure/ai-foundry/how-to/develop/trace-agents-sdk).
366+
367+
> [!NOTE]
368+
> When using Azure Monitor for your telemetry, you need to install the `azure-monitor-opentelemetry` package explicitly, as it is not included by default with Agent Framework.
346369
347370
## Next steps
348371

@@ -352,4 +375,3 @@ For more advanced observability scenarios and examples, see the [Agent Observabi
352375
> [Persisting conversations](./persisted-conversation.md)
353376
354377
::: zone-end
355-

0 commit comments

Comments
 (0)