durable: extract trace context from checkpoints and input payload#818
durable: extract trace context from checkpoints and input payload#818joeyzhao2018 wants to merge 13 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 20b00544e3
ℹ️ 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".
…k.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
| return extract_context_from_lambda_context(lambda_context) | ||
|
|
||
|
|
||
| def _extract_context_from_durable_checkpoint(operation): |
There was a problem hiding this comment.
nit: should these functions live in datadog_lambda/durable.py?
|
|
||
| # Checkpoints are written by dd-trace-py as x-datadog-* headers, so extract | ||
| # directly and bypass DD_TRACE_PROPAGATION_STYLE_EXTRACT on purpose. | ||
| return _DatadogMultiHeader._extract(result) |
There was a problem hiding this comment.
Can this cause issues if tomorrow ddtrace refactors this class?
| elif isinstance(event, dict) and "DurableExecutionArn" in event: | ||
| context = extract_context_from_durable_execution(event) |
There was a problem hiding this comment.
What happens in the first invocation here? isinstance(event, dict) and "DurableExecutionArn" in event are both true, but context will be None because there is still no _datadog_N entry.
Do we expect the first invocation to extract the context with the other methods?
Summary
Adds Datadog trace-context extraction for AWS Lambda Durable Execution events.
The tracecontext propagation injection (i.e. checkpoint creation) part is done in dd-trace-py PR#17773
Durable executions can resume with prior execution state instead of receiving the original trigger shape directly. This change teaches
extract_dd_trace_contextto recover Datadog propagation context from durable execution checkpoints, or from the original execution input payload when no checkpoint exists.Changes
DurableExecutionArn.InitialExecutionState.Operationswhether it is provided as a list or operation map._datadog_{N}checkpoint operation.ExecutionDetails.InputPayload.Testing
python -m pytest -o addopts='' tests/test_tracing.py::TestExtractAndGetDDTraceContext::test_extracts_durable_trace_context_from_latest_checkpoint_operation_map tests/test_tracing.py::TestExtractAndGetDDTraceContext::test_extracts_durable_trace_context_from_input_payload_when_no_checkpoint