Skip to content

adding test for trace_function decorator#45037

Merged
M-Hietala merged 4 commits intomainfrom
m-hietala/adding_test_for_trace_function_decorator
Feb 5, 2026
Merged

adding test for trace_function decorator#45037
M-Hietala merged 4 commits intomainfrom
m-hietala/adding_test_for_trace_function_decorator

Conversation

@M-Hietala
Copy link
Contributor

adding test for trace_function decorator

Copy link
Contributor

Copilot AI left a 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 comprehensive test coverage for the trace_function decorator, which is used to trace function calls using OpenTelemetry. The PR includes both synchronous and asynchronous test suites, along with minor improvements to the underlying implementation.

Changes:

  • Added comprehensive test suite for synchronous functions with the trace_function decorator
  • Added comprehensive test suite for asynchronous functions with the trace_function decorator
  • Improved the implementation to use inspect.iscoroutinefunction instead of asyncio.iscoroutinefunction
  • Fixed the parameter sanitization logic to correctly handle positional arguments, keyword arguments, and default values
  • Enhanced tracer initialization to occur at function execution time rather than decoration time

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
sdk/ai/azure-ai-projects/tests/agents/telemetry/test_trace_function_decorator.py New test file with 13 comprehensive test cases for synchronous functions, covering primitives, collections, custom span names, exceptions, and mixed parameter types
sdk/ai/azure-ai-projects/tests/agents/telemetry/test_trace_function_decorator_async.py New test file with 15 comprehensive test cases for asynchronous functions, mirroring sync tests plus additional coverage for default parameters
sdk/ai/azure-ai-projects/azure/ai/projects/telemetry/_trace_function.py Implementation improvements: changed from asyncio to inspect for coroutine detection, moved tracer initialization to execution time, and fixed parameter handling logic

@M-Hietala M-Hietala merged commit cb212d8 into main Feb 5, 2026
21 checks passed
@M-Hietala M-Hietala deleted the m-hietala/adding_test_for_trace_function_decorator branch February 5, 2026 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants