Skip to content

Commit c003763

Browse files
committed
fixes
1 parent dbed11b commit c003763

File tree

2 files changed

+8
-45
lines changed

2 files changed

+8
-45
lines changed

articles/ai-foundry/how-to/develop/trace-agents-sdk.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@ ms.custom:
1616
- build-2025
1717
---
1818

19-
# Tracing your AI application (preview)
19+
# Trace your AI agents using Azure AI Foundry SDK (preview)
2020

2121
[!INCLUDE [feature-preview](../../includes/feature-preview.md)]
2222

23-
Tracing provides deep visibility into execution of your application by capturing detailed telemetry at each execution step. This helps diagnose issues and enhance performance by identifying problems such as inaccurate tool calls, misleading prompts, high latency, low-quality evaluation scores, and more.
24-
25-
This article walks you through how to instrument tracing in your AI applications using OpenTelemetry and Azure Monitor for enhanced observability and debugging.
23+
This article walks you through how to instrument tracing in agents using Azure AI Foundry SDK with OpenTelemetry and Azure Monitor for enhanced observability and debugging.
2624

2725
Here's a brief overview of key concepts before getting started:
2826

articles/ai-foundry/how-to/develop/trace-application.md

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: How to trace AI applications using OpenAI SDK
33
titleSuffix: Azure AI Foundry
4-
description: This article provides instructions on how to trace your application with Azure AI Inference SDK.
4+
description: Learn how to trace applications that uses OpenAI SDK in Azure AI Foundry
55
author: lgayhardt
66
ms.author: lagayhar
77
manager: scottpolly
@@ -11,7 +11,7 @@ ms.service: azure-ai-foundry
1111
ms.topic: how-to
1212
---
1313

14-
# How to trace AI applications using OpenAI SDK
14+
# Trace AI applications using OpenAI SDK
1515

1616
Tracing provides deep visibility into execution of your application by capturing detailed telemetry at each execution step. This helps diagnose issues and enhance performance by identifying problems such as inaccurate tool calls, misleading prompts, high latency, low-quality evaluation scores, and more.
1717

@@ -23,8 +23,6 @@ To complete this tutorial you need:
2323

2424
* An Azure AI Foundry project created.
2525

26-
> Azure AI Foundry projects uses Azure Application Insights to store traces for your application. While this tutorial uses an Azure AI Foundry project, you can also send your traces directly to any Azure Application Insight resource.
27-
2826
* An AI application that uses **OpenAI SDK** to make calls to models hosted in Azure AI Foundry.
2927

3028

@@ -72,7 +70,7 @@ The following steps show how to configure:
7270

7371
If you are using the OpenAI SDK to develop intelligent applications you can instrument it so traces are sent to Azure AI Foundry. Follow this steps:
7472

75-
1. Install `azure-ai-projects`, `azure-monitor-opentelemetry-exporter`, and `opentelemetry-instrumentation-openai-v2` in your environment. The following example uses `pip`:
73+
1. Install `azure-ai-projects`, `azure-monitor-opentelemetry`, and `opentelemetry-instrumentation-openai-v2` in your environment. The following example uses `pip`:
7674

7775
```console
7876
pip install azure-ai-projects azure-monitor-opentelemetry-exporter opentelemetry-instrumentation-openai-v2
@@ -214,45 +212,12 @@ Configure tracing as follows:
214212
from opentelemetry import trace
215213
from opentelemetry.sdk.trace import TracerProvider
216214
from opentelemetry.sdk.trace.export import SimpleSpanProcessor, ConsoleSpanExporter
215+
from azure.ai.projects import enable_telemetry
217216

218217
span_exporter = ConsoleSpanExporter()
219218
tracer_provider = TracerProvider()
220219
tracer_provider.add_span_processor(SimpleSpanProcessor(span_exporter))
221220
trace.set_tracer_provider(tracer_provider)
222-
```
223-
224-
1. You can also make this decision based on if a project context is available:
225221

226-
```python
227-
from opentelemetry import trace
228-
from opentelemetry.sdk.trace import TracerProvider
229-
from opentelemetry.sdk.trace.export import SimpleSpanProcessor, BatchSpanProcessor, ConsoleSpanExporter
230-
from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter
231-
232-
from azure.ai.projects import AIProjectClient
233-
from azure.identity import DefaultAzureCredential
234-
235-
try:
236-
project_client = AIProjectClient.from_connection_string(
237-
credential=DefaultAzureCredential(),
238-
endpoint="https://<your-resource>.services.ai.azure.com/api/projects/<your-project>",
239-
)
240-
241-
connection_string = project_client.telemetry.get_connection_string()
242-
except:
243-
connection_string = None
244-
245-
tracer_provider = TracerProvider()
246-
247-
if connection_string:
248-
# Use Azure
249-
exporter = AzureMonitorTraceExporter(connection_string=connection_string)
250-
span_processor = BatchSpanProcessor(exporter)
251-
else:
252-
# Use console
253-
span_exporter = ConsoleSpanExporter()
254-
span_processor = SimpleSpanProcessor(span_exporter)
255-
256-
tracer_provider.add_span_processor(span_processor)
257-
trace.set_tracer_provider(tracer_provider)
258-
```
222+
enable_telemetry(destination=sys.stdout)
223+
```

0 commit comments

Comments
 (0)