feat(aws-lambda-microvm): refresh identity on run hook - #19781
feat(aws-lambda-microvm): refresh identity on run hook#19781litianningdatadog wants to merge 1 commit into
Conversation
Codeowners resolved asResolved from the full PR diff against |
Circular import analysis
|
|
Dependency direction analysis
|
BenchmarksBenchmark execution time: 2026-08-20 11:54:47 Comparing candidate commit 621c074 in PR branch Found 0 performance improvements and 4 performance regressions! Performance is the same for 382 metrics, 9 unstable metrics.
|
There was a problem hiding this comment.
Pull request overview
This PR activates “identity refresh” for AWS Lambda MicroVM restores by hooking the earliest shared platform signal (POST /aws/lambda-microvms/runtime/v1/run) into the existing core.WEB_REQUEST_STARTING event, ensuring runtime- and identity-bound components get refreshed once per process in MicroVM environments.
Changes:
- Add MicroVM
/runhook matching + once-per-process identity refresh registration toddtrace.internal.runtime. - Expand runtime-id tests to cover exact hook matching, ordering (pre-root-span), and concurrency behavior.
- Update web framework tests to use the real MicroVM hook path constant and add a release note.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| ddtrace/internal/runtime/init.py | Registers a MicroVM-only WEB_REQUEST_STARTING listener to refresh identity once when the exact /run hook is observed. |
| tests/tracer/runtime/test_runtime_id.py | Adds subprocess tests for hook matching, ordering vs root span creation, concurrency safety, and non-MicroVM no-op behavior. |
| tests/contrib/asgi/test_microvm_identity_refresh.py | Uses MICROVM_RUN_HOOK_PATH for request-start dispatch assertions in ASGI middleware tests. |
| tests/contrib/bottle/test_microvm_identity_refresh.py | Uses MICROVM_RUN_HOOK_PATH for request-start dispatch assertions in Bottle integration tests. |
| tests/contrib/cherrypy/test_microvm_identity_refresh.py | Uses MICROVM_RUN_HOOK_PATH for request-start dispatch assertions in CherryPy integration tests. |
| tests/contrib/django/test_microvm_identity_refresh.py | Uses MICROVM_RUN_HOOK_PATH for request-start dispatch assertions in Django integration tests. |
| tests/contrib/falcon/test_microvm_identity_refresh.py | Uses MICROVM_RUN_HOOK_PATH for request-start dispatch assertions in Falcon integration tests. |
| tests/contrib/flask/test_microvm_identity_refresh.py | Uses MICROVM_RUN_HOOK_PATH for request-start dispatch assertions (including WSGI environ) in Flask integration tests. |
| tests/contrib/http_server/test_microvm_identity_refresh.py | Uses MICROVM_RUN_HOOK_PATH for request-start dispatch assertions in http.server integration tests. |
| tests/contrib/molten/test_microvm_identity_refresh.py | Uses MICROVM_RUN_HOOK_PATH for request-start dispatch assertions in Molten integration tests. |
| tests/contrib/pyramid/test_microvm_identity_refresh.py | Uses MICROVM_RUN_HOOK_PATH for request-start dispatch assertions in Pyramid integration tests (including tracing-disabled path). |
| tests/contrib/sanic/test_sanic.py | Uses MICROVM_RUN_HOOK_PATH for request-start dispatch assertions in Sanic integration tests. |
| tests/contrib/tornado/test_microvm_identity_refresh.py | Uses MICROVM_RUN_HOOK_PATH for request-start dispatch assertions in Tornado integration tests. |
| releasenotes/notes/aws-lambda-microvm-identity-refresh-3a672cd6bcbad16d.yaml | Documents MicroVM-only stable identifier regeneration behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| import threading | ||
| import typing as t | ||
| import uuid | ||
| import weakref | ||
|
|
||
| from ddtrace.internal import core | ||
| from ddtrace.internal import forksafe |
c992c42 to
d424d55
Compare
03c4230 to
55f826c
Compare
AWS Lambda MicroVM instances restored from the same image start with the same in-memory runtime id and Remote Config client id. The platform's /run lifecycle request is the earliest common signal that a restored instance is becoming active. Register the web request listener only inside MicroVM images, match the fixed POST /run hook, and refresh identity once per process. Stacked web layers can observe the same request without rotating identity more than once.
55f826c to
621c074
Compare
Description
AWS Lambda MicroVM instances created from the same image start with the same in-memory runtime id and Remote Config client id. The platform
POST /aws/lambda-microvms/runtime/v1/runrequest is the earliest shared signal that a restored instance is becoming active.This registers the web request listener only inside MicroVM images, matches the fixed
/runhook, and refreshes identity once per process. The once-only guard handles stacked web layers observing the same platform request.Testing
Added hook matcher coverage for exact match, ignored requests, listener registration outside MicroVMs, root-span ordering, and concurrent observations. Updated web event tests to use the real MicroVM hook path.
Risks
Medium. This is the PR that activates identity refresh from request dispatch, but only when
AWS_LAMBDA_MICROVM_IMAGE_ARNis present and only for the fixed platform hook.Additional Notes
Stacked on #19780.