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: articles/ai-foundry/how-to/develop/trace-application.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: How to trace AI applications using OpenAI SDK
3
3
titleSuffix: Azure AI Foundry
4
-
description: Learn how to trace applications that uses OpenAI SDK in Azure AI Foundry
4
+
description: Learn how to trace applications that use OpenAI SDK in Azure AI Foundry
5
5
author: lgayhardt
6
6
ms.author: lagayhar
7
7
manager: scottpolly
@@ -13,13 +13,13 @@ ms.topic: how-to
13
13
14
14
# Trace AI applications using OpenAI SDK
15
15
16
-
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.
16
+
Tracing provides deep visibility into execution of your application by capturing detailed telemetry at each execution step. Such helps diagnose issues and enhance performance by identifying problems such as inaccurate tool calls, misleading prompts, high latency, low-quality evaluation scores, and more.
17
17
18
18
This article explains how to implement tracing for AI applications using OpenAI SDK with OpenTelemetry in Azure AI Foundry.
19
19
20
20
## Prerequisites
21
21
22
-
To complete this tutorial you need:
22
+
Ensure you have the following:
23
23
24
24
* An Azure AI Foundry project created.
25
25
@@ -40,7 +40,7 @@ The following steps show how to configure:
40
40
41
41
:::image type="content" source="../../media/how-to/develop/trace-application/configure-app-insight.png" alt-text="A screenshot showing how to configure Azure Application Insights to the Azure AI Foundry resource." lightbox="../../media/how-to/develop/trace-application/configure-app-insight.png":::
42
42
43
-
4. To reuse an existing Azure Application Insights, use the dropdown **Application Insights resource name** to locate the resource and select **Connect**.
43
+
4. To reuse an existing Azure Application Insights, use the drop-down **Application Insights resource name** to locate the resource and select **Connect**.
44
44
45
45
> [!TIP]
46
46
> To connect to an existing Azure Application Insights, you need at least contributor access to the Azure AI Foundry resource (or Hub).
@@ -68,7 +68,7 @@ The following steps show how to configure:
68
68
69
69
## Instrument the OpenAI SDK
70
70
71
-
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:
71
+
If you are using the OpenAI SDK to develop intelligent applications you can instrument it so traces are sent to Azure AI Foundry. Follow these steps:
72
72
73
73
1. Install `azure-ai-projects`, `azure-monitor-opentelemetry`, and `opentelemetry-instrumentation-openai-v2` in your environment. The following example uses `pip`:
74
74
@@ -111,7 +111,7 @@ If you are using the OpenAI SDK to develop intelligent applications you can inst
1. By default, OpenTelemetry doesn't capture the inputs and outputs. To enable that, use the environment variable `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true`. Ensure this environment variable is configure in the environment level where you code is running.
114
+
1. By default, OpenTelemetry doesn't capture the inputs and outputs. To enable that, use the environment variable `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true`. Ensure this environment variable is configured in the environment level where your code is running.
115
115
116
116
1. Use the OpenAI SDK in the same way you are used to:
117
117
@@ -130,15 +130,15 @@ If you are using the OpenAI SDK to develop intelligent applications you can inst
130
130
131
131
:::image type="content" source="../../media/how-to/develop/trace-application/tracing-display-simple.png" alt-text="A screenshot showing how a simple chat completion request is displayed in the trace." lightbox="../../media/how-to/develop/trace-application/tracing-display-simple.png":::
132
132
133
-
1. When developing complex applications, it may be useful to capture sections of your code that mixes business logic with models. You can do that by first getting an instance of the current tracer.
133
+
1. It may be useful to capture sections of your code that mixes business logic with models when developing complex applications. You can do that by first getting an instance of the current tracer.
134
134
135
135
```python
136
136
from opentelemetry import trace
137
137
138
138
tracer = trace.get_tracer(__name__)
139
139
```
140
140
141
-
1. Then, use decorators in your method to capture specific scenarios in your code that you are interested in. The following example assess if a list of claims with a list of contexts.
141
+
1. Then, use decorators in your method to capture specific scenarios in your code that you are interested in. The following example assesses if a list of claims with a list of contexts.
@@ -167,7 +167,7 @@ If you are using the OpenAI SDK to develop intelligent applications you can inst
167
167
return responses
168
168
```
169
169
170
-
1. Then, traces will look as follow:
170
+
1. Then, traces will look as follows:
171
171
172
172
:::image type="content" source="../../media/how-to/develop/trace-application/tracing-display-decorator.png" alt-text="A screenshot showing how a method using a decorator is displayed in the trace." lightbox="../../media/how-to/develop/trace-application/tracing-display-decorator.png":::
0 commit comments