feat(profiling): link task samples to origin task#19082
Conversation
Codeowners resolved as |
Circular import analysis
|
🎉 All green!🧪 All tests passed 🔗 Commit SHA: 83a5e40 | Docs | Datadog PR Page | Give us feedback! |
2beae5a to
6293dda
Compare
6293dda to
da40178
Compare
da40178 to
f233a6f
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6293ddaa8e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
f233a6f to
bb5b050
Compare
0d6e038 to
2170d10
Compare
f167145 to
66176fd
Compare
taegyunkim
left a comment
There was a problem hiding this comment.
With this PR, do we expect to see any difference on UI (timeline maybe?) for applications using ThreadPoolExecutor? or this is PR is a necessary step towards to have such changes?
@taegyunkim Nothing changed in UI after this. But its a necessary step |
4d1bffd to
519d509
Compare
519d509 to
ab894eb
Compare
taegyunkim
left a comment
There was a problem hiding this comment.
Thanks! now it's just formatting ci
ab894eb to
ef7b1ac
Compare
wantsui
left a comment
There was a problem hiding this comment.
LGTM from an integrations standpoint

PROF-15417
local
Description
When an asyncio task offloads blocking work to a
ThreadPoolExecutor(await loop.run_in_executor(None, fn)), that work runs on a pool worker thread that has no asyncio task of its own. Today those samples can't be tied back to the task that submitted and is awaiting them.This adds two pprof labels on the executor worker thread's samples:
id()of the submitting asyncio taskorigin task id is deliberately the same value the profiler already emits as task id for the task on its event-loop thread, so the offloaded work correlates back to the awaiting task with no new join key.
The
futuresintegration already wrapsThreadPoolExecutor.submitand runs the work through an intermediate_wrap_executionon the worker thread. We capture the current asyncio task at submit time, and at execution time register athread_id->{task id, name}entry in a native per-thread map for the duration of the job, clearing it in afinally. The stack renderer stamps the labels by looking that map up by sampled thread id. The worker thread isnt predicted ahead of time, rather, the link is made on whichever worker the pool assigns and torn down when the job completes, so pool reuse is handled correctly.Testing
Risks
Additional Notes