Repository navigation
feat(instrumentation): await callbacks at function start - #10123
juan-fernandez merged 3 commits into
Conversation
Overall package sizeSelf size: 8.74 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.4.0 | 127.33 kB | 447.04 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
BenchmarksBenchmark execution time: 2026-09-03 08:18:15 Comparing candidate commit 35e6b9c in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 2313 metrics, 15 unstable metrics.
|
|
✅ All CI checks and tests passed. 🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 35e6b9c | Docs | View more details | Give us feedback! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #10123 +/- ##
========================================
Coverage 98.63% 98.63%
========================================
Files 1002 1002
Lines 154897 154945 +48
Branches 13358 13607 +249
========================================
+ Hits 152779 152827 +48
Misses 2118 2118 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
/datadog autotest review |
There was a problem hiding this comment.
The new transform inserts callback statements before a function directive. This action can disable local strict mode.
🤖 Datadog Autotest · Commit 572c8ff · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 572c8ff620
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
/datadog autotest review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
More details
The PR adds a transform that awaits a context callback at function start.
The latest commit handles direct function-node queries.
It also preserves directive prologues before callback insertion.
The earlier strict-mode and skipped-rewrite issues are fixed.
No open findings remain.
🤖 Datadog Autotest · Commit 35e6b9c · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
rochdev
left a comment
There was a problem hiding this comment.
Approving to unblock, but could you look into a follow-up to see if maybe all of the different awaitContextX could be combined somehow? Maybe instead of targeting the wrapping function it could target the block or statement itself? Then a single transform would be usable in any case instead of needing special casing for every blocking scenario.
|
Follow-up opened as draft PR #10157, starting from master. It replaces the function-start and try-start variants with one awaitContextCallback transform that targets the actual BlockStatement, while preserving the IfStatement condition recheck behavior. |
What does this PR do?
Adds
awaitContextCallbackAtFunctionStart, a rewriter transform that awaits a tracing-context callback at the start of an instrumented async function.It uses the same callback validation, tracing-wrapper validation,
callbackThishandling, idempotency check, and failure-isolated invocation as the existing callback transforms.Motivation
The existing transforms only support conditional branches and the start of a
tryblock. They cannot insert a callback before statements that appear before thattry.For example:
awaitContextCallbackAtTryStartruns afterrunBeforeHooks(). The new transform can run beforerunBeforeHooks()while keeping the generated callback isolated from application failures:Additional Notes
This PR contains generic rewriter functionality only. The WebdriverIO and RUM use case remains in stacked draft PR #10049.
Validation:
./node_modules/.bin/mocha packages/datadog-instrumentations/test/helpers/rewriter/index.spec.js(40 passing)