Skip to content

fix(profiling): swallow RuntimeError from current_task() in asyncio wrappers - #20006

Closed
vlad-scherbich wants to merge 2 commits into
mainfrom
vlad/315-profiling-asyncio-swallow
Closed

fix(profiling): swallow RuntimeError from current_task() in asyncio wrappers#20006
vlad-scherbich wants to merge 2 commits into
mainfrom
vlad/315-profiling-asyncio-swallow

Conversation

@vlad-scherbich

@vlad-scherbich vlad-scherbich commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Description

Delta vs #19269: tolerates RuntimeError from asyncio.current_task() in the affected _GatheringFuture and _wait wrapper paths, skipping link_tasks when no running loop is available.

This is a narrowly scoped runtime fix. It does not enable profiling broadly, add the native build, or change the #19272 sys.monitoring path.

Layer Meaning Which PR
Compiled Native prerequisite #19269
Armed RuntimeError tolerance in two wrappers this PR
Observable No standalone support claim

Testing

Risks

Additional Notes

changelog/no-changelog.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codeowners resolved as

Resolved from the full PR diff against vlad/ddtracepy-315-profiling-native using the target branch CODEOWNERS file.
CODEOWNERS team requests not listed below are not required by the current file set.

ddtrace/profiling/_asyncio.py                                           @DataDog/profiling-python

@vlad-scherbich vlad-scherbich added the changelog/no-changelog A changelog entry is not required for this PR. label Sep 1, 2026
@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Sep 1, 2026

Copy link
Copy Markdown

Circular import analysis

⚠️ Existing circular imports

There are 3 circular imports that already exist on the base branch and have not been changed by this PR.

ddtrace.errortracking._handled_exceptions.bytecode_injector -> ddtrace.errortracking._handled_exceptions.callbacks -> ddtrace.errortracking._handled_exceptions.collector -> ddtrace.errortracking._handled_exceptions.bytecode_reporting -> ddtrace.errortracking._handled_exceptions.bytecode_injector
ddtrace.llmobs -> ddtrace.llmobs._evaluators -> ddtrace.llmobs._evaluators.format -> ddtrace.llmobs._experiment -> ddtrace.llmobs
ddtrace.appsec._asm_request_context -> ddtrace.appsec._iast._iast_request_context_base -> ddtrace.appsec._iast._iast_env -> ddtrace.appsec._iast.reporter -> ddtrace.appsec._exploit_prevention.stack_traces -> ddtrace.appsec._asm_request_context

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Sep 1, 2026

Copy link
Copy Markdown

Dependency direction analysis

⚠️ Existing dependency direction violations

There are 230 dependency direction violations that already exist on the base branch and have not been changed by this PR.

Show existing violations (showing 5 of 230 highest severity)
ddtrace.internal.tracemethods -×-> ddtrace.trace  (internal-core -> product:tracing, score=134)
ddtrace.llmobs._integrations.langgraph -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=132)
ddtrace.llmobs._integrations.google_adk -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=132)
ddtrace.appsec._contrib.django -×-> ddtrace.trace  (product:appsec -> product:tracing, score=132)
ddtrace.llmobs._integrations.openai_agents -×-> ddtrace.trace  (product:llmobs -> product:tracing, score=132)

To see all violations, download the layers-base.json and layers-pr.json artifacts from this CI job and run:

uv run --script scripts/import-analysis/layers.py compare layers-base.json layers-pr.json

@datadog-prod-us1-3

datadog-prod-us1-3 Bot commented Sep 1, 2026

Copy link
Copy Markdown

Pipelines  Tests

⚠️ Warnings

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 7 Pipeline jobs failed

Pytorch Unit Tests (with GPU) | unit-tests — 🔧 Needs a code fix, caused by this PR

View more details · View in GitHub Actions

Import error: No module named 'tests._ddtest_env_helpers' during test execution in tests/profiling/test_pytorch.py.

Changelog | Validate changelog

View more details · View in GitHub Actions

Release note not found. Fix and feat PRs must have a changelog entry.

DataDog/apm-reliability/dd-trace-py | download_dependency_wheels: [3.15.0rc1, 3.15]

View more details · View in GitLab

View all 7 failed jobs.

📋 Copy fix prompt
CI on my pull request is failing. Help me find and fix the root cause of each failing job below — they were flagged as caused by changes in this PR, so focus on the diff. For each job, explain the failure and propose a fix.

Before you start, set up the Datadog software-delivery tooling so you can
query the CI data yourself:

1. Check whether you already have the Datadog software-delivery MCP tools
   (e.g. a `search_datadog_ci_pipeline_events` tool) and the `unblock-pr` skill.
2. If either is missing, STOP and ask me for permission before installing
   anything. Do not install or run anything until I have said yes.
3. Only with my explicit approval, set up the Datadog software-delivery MCP
   server and skills by following:
     https://docs.datadoghq.com/getting_started/software_delivery_mcp_tools/
   then restart so the skill is picked up.
4. If I decline, skip all of the above and work from the context below alone.

Then run /unblock-pr — it will pull the CI data itself. The job context below is what we already know.

If /unblock-pr is not available — because I declined the setup above, or it did not install — work from the context below instead.

Datadog has already classified this failure as caused by changes in this PR.
Take that as given and work the fix:

1. Locate the change. Diff this branch against its base and find the change
   that produces this error. Explain the mechanism, don't just name a file:
     git fetch origin && git diff $(git merge-base origin/main HEAD)...HEAD
2. Reproduce it locally. Run the failing job's command or test before
   proposing anything.
3. Propose the smallest fix that addresses the root cause — not a workaround,
   not a broadened assertion, not a disabled or skipped test.
4. Re-run the same command to confirm, and say exactly what you ran.
5. If the failure turns out to be intermittent rather than deterministic, say
   so plainly instead of "fixing" it — that is a flaky test, and patching it
   hides the problem.

If the right move is to re-run the job rather than change code, use the job
link in the context below. For GitHub Actions: `gh run rerun <run-id> --failed`,
where the run ID is the number after `/runs/` in that URL (not the trailing
number, which is the job ID).

Branch: vlad/315-profiling-asyncio-swallow

Pytorch Unit Tests (with GPU) | unit-tests
Commit: 2a5e6caba8baba841e8ba8394d596ea029eeb869
Error (code / test):
Import error: No module named 'tests._ddtest_env_helpers' during test execution in tests/profiling/test_pytorch.py.
CI job: https://github.com/DataDog/dd-trace-py/actions/runs/33909030076/job/101140795327

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 10fad6b | Docs | View more details | Give us feedback!

@vlad-scherbich
vlad-scherbich force-pushed the vlad/ddtracepy-315-profiling-collectors branch from 989dea6 to 551605d Compare September 2, 2026 16:09
@vlad-scherbich
vlad-scherbich force-pushed the vlad/315-profiling-asyncio-swallow branch 2 times, most recently from 86d787a to a3c7591 Compare September 2, 2026 19:10
@vlad-scherbich
vlad-scherbich force-pushed the vlad/ddtracepy-315-profiling-collectors branch from 551605d to 33d1ad8 Compare September 2, 2026 19:10
Base automatically changed from vlad/ddtracepy-315-profiling-collectors to vlad/ddtracepy-315-profiling-native September 2, 2026 19:23
@vlad-scherbich
vlad-scherbich force-pushed the vlad/315-profiling-asyncio-swallow branch from a3c7591 to 89f7376 Compare September 2, 2026 19:34
@vlad-scherbich
vlad-scherbich force-pushed the vlad/ddtracepy-315-profiling-native branch from df5e2f7 to 6d624f8 Compare September 2, 2026 20:15
@vlad-scherbich
vlad-scherbich force-pushed the vlad/315-profiling-asyncio-swallow branch 2 times, most recently from 129f3ce to 2a0b92f Compare September 3, 2026 02:10
Carry the profiling-native C++, Rust-header, CMake, setup, test, and CI changes for Python 3.15.
@vlad-scherbich
vlad-scherbich force-pushed the vlad/ddtracepy-315-profiling-native branch from 79b8faf to ddba58a Compare September 4, 2026 18:57
@vlad-scherbich
vlad-scherbich force-pushed the vlad/315-profiling-asyncio-swallow branch from 2a0b92f to 10fad6b Compare September 4, 2026 19:02
Base automatically changed from vlad/ddtracepy-315-profiling-native to main September 9, 2026 14:25
@vlad-scherbich

Copy link
Copy Markdown
Contributor Author

main already gates these wrappers

@vlad-scherbich

Copy link
Copy Markdown
Contributor Author

reopened — close was meant for a different leftover PR

@vlad-scherbich

Copy link
Copy Markdown
Contributor Author

reopened — close was meant for a different leftover PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/no-changelog A changelog entry is not required for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant