dd-trace-py icon indicating copy to clipboard operation
dd-trace-py copied to clipboard

chore(asyncio): parent spans on task creation

Open mabdinur opened this issue 11 months ago • 4 comments

  • Reverts deprecating the asyncio integration.
  • Adds support for propagating the current active trace context to newly created tasks (currently context is propagated when a task is executed and not when it is created).

Addressing failing test case: https://app.circleci.com/pipelines/github/DataDog/dd-trace-py/57636/workflows/9927164f-a99a-401f-9067-e143aa360d32/jobs/3653658

Resolves: https://github.com/DataDog/dd-trace-py/issues/8637

Checklist

  • [ ] Change(s) are motivated and described in the PR description
  • [ ] Testing strategy is described if automated tests are not included in the PR
  • [ ] Risks are described (performance impact, potential for breakage, maintainability)
  • [ ] Change is maintainable (easy to change, telemetry, documentation)
  • [ ] Library release note guidelines are followed or label changelog/no-changelog is set
  • [ ] Documentation is included (in-code, generated user docs, public corp docs)
  • [ ] Backport labels are set (if applicable)
  • [ ] If this PR changes the public interface, I've notified @DataDog/apm-tees.
  • [ ] If change touches code that signs or publishes builds or packages, or handles credentials of any kind, I've requested a review from @DataDog/security-design-and-guidance.

Reviewer Checklist

  • [x] Title is accurate
  • [x] All changes are related to the pull request's stated goal
  • [x] Description motivates each change
  • [x] Avoids breaking API changes
  • [x] Testing strategy adequately addresses listed risks
  • [x] Change is maintainable (easy to change, telemetry, documentation)
  • [x] Release note makes sense to a user of the library
  • [x] Author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • [x] Backport labels are set in a manner that is consistent with the release branch maintenance policy

mabdinur avatar Mar 12 '24 13:03 mabdinur

TODO: Investigate failing async framework tests

mabdinur avatar Mar 12 '24 15:03 mabdinur

Datadog Report

Branch report: munir/fix-asyncio-scheduling Commit report: 87536a2 Test service: dd-trace-py

:white_check_mark: 0 Failed, 2117 Passed, 87 Skipped, 1h 19m 43s Total duration (7m 21.48s time saved)

Benchmarks

Benchmark execution time: 2024-03-18 17:43:10

Comparing candidate commit ad538aab3f75d771e4dd2dfe565f15e86a215147 in PR branch munir/fix-asyncio-scheduling with baseline commit 79fcb4830fa7e20f323ae0198b08451a090526e3 in branch main.

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

scenario:flasksimple-tracer

  • 🟥 execution_time [+196.242µs; +244.846µs] or [+3.112%; +3.883%]

scenario:sethttpmeta-useragentvariant_not_exists_2

  • 🟥 max_rss_usage [+449.787KB; +760.991KB] or [+2.083%; +3.525%]

pr-commenter[bot] avatar Mar 13 '24 15:03 pr-commenter[bot]

TODO: wrap a lower level of create_task

mabdinur avatar Mar 15 '24 21:03 mabdinur