-
Notifications
You must be signed in to change notification settings - Fork 5k
adding function tracer #50990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
adding function tracer #50990
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new FunctionTracer feature that captures and exports function call telemetry via OpenTelemetry, complete with sample code, utilities, tests, and documentation updates.
- Introduces the
FunctionTracer
class inTelemetry/FunctionTracer.cs
for automatic parameter and return-value tracing. - Adds test utilities (
MemoryTraceExporter
,GenAiTraceVerifier
) and extensiveFunctionTracerTests
. - Updates project files for telemetry dependencies and expands the README with telemetry samples.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
sdk/ai/Azure.AI.Projects/tests/Utilities/MemoryTraceExporter.cs | In-memory exporter for capturing Activity objects in tests |
sdk/ai/Azure.AI.Projects/tests/Utilities/GenAITraceVerifier.cs | Utility to verify span attributes and events in tests |
sdk/ai/Azure.AI.Projects/tests/Samples/Telemetry/Sample_Telemetry_FunctionTracer.cs | Sample code showing FunctionTracer usage for sync/async functions |
sdk/ai/Azure.AI.Projects/tests/FunctionTracerTests.cs | Comprehensive tests covering various tracing scenarios |
sdk/ai/Azure.AI.Projects/tests/Azure.AI.Projects.Tests.csproj | Adds telemetry exporter package references |
sdk/ai/Azure.AI.Projects/src/Telemetry/FunctionTracer.cs | Core implementation of the FunctionTracer API |
sdk/ai/Azure.AI.Projects/src/Azure.AI.Projects.csproj | Registers the Telemetry folder in the main project |
sdk/ai/Azure.AI.Projects/README.md | Inserts a Telemetry section with sample snippets |
Comments suppressed due to low confidence (1)
sdk/ai/Azure.AI.Projects/tests/FunctionTracerTests.cs:153
- The test calls
_exporter.ForceFlush()
, butMemoryTraceExporter
does not implementForceFlush
. You should call_tracerProvider.ForceFlush()
(or the tracer provider's flush) to ensure spans are exported.
_exporter.ForceFlush();
using OpenTelemetry; | ||
using OpenTelemetry.Trace; | ||
using System.Diagnostics; | ||
using Moq; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the unused using Moq;
directive, as this file does not reference Moq.
using Moq; |
Copilot uses AI. Check for mistakes.
sdk/ai/Azure.AI.Projects/README.md
Outdated
A helper class is provided to trace your own functions. The trace functions in the class will log function parameters and the return value for supported types. | ||
Note that this helper class will log the parameters and return value always when tracing is enabled, so be mindful with sensitive data. | ||
|
||
Here are is a sample async function that we want to trace: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct the grammar here to "Here is a sample async function that we want to trace:".
Here are is a sample async function that we want to trace: | |
Here is a sample async function that we want to trace: |
Copilot uses AI. Check for mistakes.
sdk/ai/Azure.AI.Projects/README.md
Outdated
} | ||
``` | ||
|
||
Here are is a sample sync function that we want to trace: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct the grammar here to "Here is a sample sync function that we want to trace:".
Here are is a sample sync function that we want to trace: | |
Here is a sample sync function that we want to trace: |
Copilot uses AI. Check for mistakes.
API Change CheckAPIView identified API level changes in this PR and created the following API reviews |
adding function tracer