You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: agent-framework/tutorials/agents/enable-observability.md
+29-7Lines changed: 29 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -150,12 +150,16 @@ The following OpenTelemetry packages are included by default:
150
150
```text
151
151
opentelemetry-api
152
152
opentelemetry-sdk
153
-
azure-monitor-opentelemetry
154
-
azure-monitor-opentelemetry-exporter
155
153
opentelemetry-exporter-otlp-proto-grpc
156
154
opentelemetry-semantic-conventions-ai
157
155
```
158
156
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
+
159
163
## Enable OpenTelemetry in your app
160
164
161
165
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
179
183
180
184
-**`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.
181
185
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.
183
187
184
188
-**`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.
185
189
186
190
-**`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.
187
191
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
+
188
195
### Setup options
189
196
190
197
You can configure observability in three ways:
@@ -207,6 +214,7 @@ setup_observability() # Reads from environment variables
207
214
```python
208
215
from agent_framework.observability import setup_observability
209
216
217
+
# note that ENABLE_OTEL is implied to be True when calling setup_observability programmatically
210
218
setup_observability(
211
219
enable_sensitive_data=True,
212
220
otlp_endpoint="http://localhost:4317",
@@ -327,22 +335,37 @@ The following metrics are also collected:
327
335
328
336
## Azure AI Foundry integration
329
337
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:
331
339
332
340
```python
333
341
from agent_framework.azure import AzureAIAgentClient
# Automatically configures observability with Application Insights
342
352
await agent_client.setup_azure_ai_observability()
343
353
```
344
354
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
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.
346
369
347
370
## Next steps
348
371
@@ -352,4 +375,3 @@ For more advanced observability scenarios and examples, see the [Agent Observabi
0 commit comments