Skip to content
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

fix(tracer): dd_trace_methods wrapping async functions #12337

Merged
merged 10 commits into from
Feb 19, 2025

Conversation

rachelyangdog
Copy link
Contributor

@rachelyangdog rachelyangdog commented Feb 13, 2025

Resolves issue #10754

Updated trace_wrapper to check if the target function is async (using inspect.iscoroutinefunction). If it is, the wrapper uses async/await to keep the tracing span open until the coroutine truly finishes instead of closing immediately when the coroutine is created.

Checklist

  • PR author has checked that all the criteria below are met
  • The PR description includes an overview of the change
  • The PR description articulates the motivation for the change
  • The change includes tests OR the PR description describes a testing strategy
  • The PR description notes risks associated with the change, if any
  • Newly-added code is easy to change
  • The change follows the library release note guidelines
  • The change includes or references documentation updates if necessary
  • Backport labels are set (if applicable)

Reviewer Checklist

  • Reviewer has checked that all the criteria below are met
  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Newly-added code is easy to change
  • Release note makes sense to a user of the library
  • If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

@rachelyangdog rachelyangdog requested a review from a team as a code owner February 13, 2025 21:12
Copy link
Contributor

github-actions bot commented Feb 13, 2025

CODEOWNERS have been resolved as:

releasenotes/notes/dd-trace-methods-wrapping-async-functions-efa8599ac82c45f2.yaml  @DataDog/apm-python
ddtrace/internal/tracemethods.py                                        @DataDog/apm-sdk-api-python
tests/integration/test_tracemethods.py                                  @DataDog/apm-core-python

@rachelyangdog rachelyangdog added the changelog/no-changelog A changelog entry is not required for this PR. label Feb 13, 2025
@rachelyangdog rachelyangdog changed the title DD_TRACE_METHODS wrapping async functions fix(tracer): DD_TRACE_METHODS wrapping async functions Feb 13, 2025
@rachelyangdog rachelyangdog removed the changelog/no-changelog A changelog entry is not required for this PR. label Feb 13, 2025
@rachelyangdog rachelyangdog changed the title fix(tracer): DD_TRACE_METHODS wrapping async functions fix(tracer): dd_trace_methods wrapping async functions Feb 13, 2025
@datadog-dd-trace-py-rkomorn
Copy link

datadog-dd-trace-py-rkomorn bot commented Feb 13, 2025

Datadog Report

Branch report: rachel.yang/dd-trace-methods
Commit report: 688bad4
Test service: dd-trace-py

✅ 0 Failed, 130 Passed, 1184 Skipped, 1m 35.03s Total Time

@rachelyangdog rachelyangdog requested a review from a team as a code owner February 13, 2025 21:51
@rachelyangdog rachelyangdog requested a review from a team as a code owner February 13, 2025 21:58
@pr-commenter
Copy link

pr-commenter bot commented Feb 13, 2025

Benchmarks

Benchmark execution time: 2025-02-19 15:29:19

Comparing candidate commit 688bad4 in PR branch rachel.yang/dd-trace-methods with baseline commit 89689b8 in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 418 metrics, 2 unstable metrics.

Copy link
Contributor

@mabdinur mabdinur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some nits, as long as the tests pass this looks to me.

@rachelyangdog rachelyangdog enabled auto-merge (squash) February 18, 2025 20:17
@rachelyangdog rachelyangdog merged commit a04ffb0 into main Feb 19, 2025
726 checks passed
@rachelyangdog rachelyangdog deleted the rachel.yang/dd-trace-methods branch February 19, 2025 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants