chore(serverless): emit MicroVM request start for WSGI & ASGI-based applications - #19898
litianningdatadog wants to merge 1 commit into
Conversation
Codeowners resolved asResolved from the full PR diff against |
Circular import analysis
|
Dependency direction analysis
|
🎉 All green!🧪 All tests passed 🔗 Commit SHA: 7398b18 | Docs | View more details | Give us feedback! |
4aebb33 to
206cd22
Compare
206cd22 to
f3ea773
Compare
f3ea773 to
68bf61e
Compare
68bf61e to
8e26c22
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The environment detector lacks direct coverage, and the release note announces behavior completed only by a follow-up PR.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds pre-span MicroVM request detection to WSGI and ASGI instrumentation, supporting the runtime identity refresh stack.
Changes:
- Dispatches
web.request.startingfor matching MicroVM requests. - Adds explicit runtime identity refresh callbacks while preserving fork lineage.
- Adds focused integration/runtime tests and a release note.
File summaries
| File | Description |
|---|---|
ddtrace/contrib/_events/web_framework.py |
Defines the request-start event. |
ddtrace/contrib/internal/web.py |
Matches and dispatches MicroVM requests. |
ddtrace/contrib/internal/asgi/middleware.py |
Dispatches before ASGI span creation. |
ddtrace/contrib/internal/wsgi/wsgi.py |
Dispatches before WSGI span creation. |
ddtrace/internal/serverless/__init__.py |
Detects the MicroVM environment. |
ddtrace/internal/runtime/__init__.py |
Adds explicit identity refresh support. |
tests/contrib/asgi/test_asgi.py |
Tests ASGI matching and ordering. |
tests/contrib/wsgi/test_wsgi.py |
Tests WSGI request matching. |
tests/tracer/runtime/test_runtime_id.py |
Tests refresh and fork semantics. |
releasenotes/notes/add-lambda-microvm-web-request-starting-ffa6841a15e3c57c.yaml |
Announces MicroVM request detection. |
Review details
- Files reviewed: 8/8 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
8e26c22 to
cdc53d4
Compare
d28bc4e to
0d5cf10
Compare
0d5cf10 to
4654514
Compare
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 24e4d34d84
ℹ️ 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".
24e4d34 to
2d71731
Compare
jcstorms1
left a comment
There was a problem hiding this comment.
Just looked at the files we own. LGTM
2d71731 to
bfe3d91
Compare
bfe3d91 to
a44c5ce
Compare
a44c5ce to
7398b18
Compare
Stacked PRs:
Description
MicroVMs call the language runtime through a local /run endpoint before the user request is served. The identity refresh stack needs a request-start signal before the framework root span is created; otherwise the first span for a fresh MicroVM run can still pick up the previous runtime ID.
The WSGI and ASGI entry points now recognize the AWS Lambda MicroVM runtime request and emit the existing web.request.starting event before root-span creation. Normal application requests, non-MicroVM environments, and non-matching paths keep the old behavior.
Path construction is deferred until after the POST and MicroVM-environment checks, so ordinary non-POST requests avoid the additional path normalization and concatenation.
The WSGI/Django paths also now:
Reference
Testing
Added focused WSGI, ASGI, Django WSGI, and runtime-detection coverage for:
dispatching web.request.starting for the MicroVM runtime request;
preserving normal request behavior;
mounted and full-path WSGI/ASGI path representations;
skipping the MicroVM environment check for non-POST requests;
dispatching the request event before span creation in both WSGI and ASGI middleware;
preventing duplicate dispatch through nested WSGI middleware and Django WSGI instrumentation; and
MicroVM environment detection for set, unset, and whitespace-only values.
ASGI-based Django test shows the run event can be intercepted
Validation:
scripts/lint fmtscripts/lint stylescripts/lint typing13873ec7e85837Risks
Low. The new event is limited to AWS Lambda MicroVM runtime metadata and leaves non-matching ASGI/WSGI requests unchanged. This PR is internal plumbing; customer-facing release-note content belongs with follow-up PR #19939.