Repository navigation
Conversation
…ew log records Signed-off-by: Ym <[email protected]>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi, I read through the issue and wrote a fix; happy to adjust it.
Fixes #893
Thanks for writing the acceptance criteria as a table of log locations and expected
spanIdvalues; it made it easy to check each case one by one.Description of changes
With
ExecutionOtelPluginand log enrichment on, a top-level handler record carried the Invocation span and a step-body record carried the attempt span. This changes the stampedspanIdto the logical span: the Workflow span at the top level, and the Step operation span inside a step body (the same ID for every retry attempt, and a nested step uses its own). Child-context bodies already resolved to the child operation span and are unchanged.InvocationOtelPluginis untouched.The attempt span is still the current OTel span, so span parentage, attach/detach scopes and exported spans are not changed. Only
ExecutionOtelPlugin.get_current_span_context()changes: when the current span is the enclosing Workflow span it returns the Workflow context, and when it is an attempt span it returns that step's deterministic operation span context, kept in a small map filled inon_user_function_startand cleared inon_user_function_end.Design
get_current_span_context()deliberately excluded the Workflow span and returned the attempt span as is.Assumptions
operation_id_to_span_id(execution_arn, operation_id), the same ID the exported Step operation span uses. The e2e view-registration test checks this against the exportedlogged-stepspan through the real handler path.Decisions not covered by the issue or the design note
OtelContextLogFilterdocstring now describe both views, because the mapping now differs between them.Tests
Edited expectations (rule 5):
test_top_level_log_names_invocation_span_not_the_attached_workflow_spanis nowtest_top_level_log_names_the_workflow_span, andtest_step_attempt_log_names_the_attempt_spanis nowtest_step_log_names_the_step_operation_span_across_attempts, both because the issue changes the mapping they asserted. Intests/e2e/test_concurrent_log_correlation_int.pythe expected span is now read from the Workflow span for the Execution view (Invocation view unchanged). Intests/e2e/test_view_registration.pythe recovery check expects thelogged-stepoperation span for the Execution view and the attempt span for the Invocation view.Added:
test_step_log_names_the_step_operation_span_across_attempts(two attempts, same ID, Workflow restored after each) andtest_nested_step_log_names_its_own_operation_span_and_restores_child.Before the fix, 7 tests fail (the 3 unit tests above, the Workflow case of the concurrent-invocation e2e test, and 3 view-registration e2e cases). With the fix, the whole otel package suite passes: 1022 passed (unit and e2e), and
ruff checkandruff format --checkare clean. I ran this on macOS with Python 3.14 in a throwaway venv (pip install of the core and otel packages,aws-durable-execution-sdk-python-testing, opentelemetry SDK).Not run: the cloud Lambda reproduction from the issue, hatch environments, mypy, the core and examples package tests. I did not add a dedicated test for a top-level log after a durable wait and resume, or for a compatible Lambda span already being active; the Workflow span ID is derived from the execution ARN, so it is the same across invocations, but that is not asserted end to end.