Skip to content

Parent durable OTel spans to shared execution trace - #685

Draft
ayushiahjolia wants to merge 1 commit into
mainfrom
otel-shared-execution-trace
Draft

Parent durable OTel spans to shared execution trace#685
ayushiahjolia wants to merge 1 commit into
mainfrom
otel-shared-execution-trace

Conversation

@ayushiahjolia

Copy link
Copy Markdown
Contributor

Issue #, if available: #674

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Claude AI review

This PR reparents durable OTel spans (Workflow, Invocation, operations, attempts) onto one shared execution trace anchored to a propagated backend parent or a deterministic synthetic root, adds a DurableSampler/sampling-intent mechanism to resolve sampling once per invocation, and restructures context extractors to return a structured ExtractedContext. The trace-context resolution (canonical_trace_id, ExecutionTraceContext.resolve), sampling precedence, id namespacing (derive_execution_root_span_id), and the store_sampling_intent/DurableSampler wiring are internally consistent and well covered by the updated tests.

One correctness issue: both plugins now return early when execution_arn is missing without clearing _tracing_enabled, which _bind_sdk_tracer() set to True a few lines earlier. Because subsequent operation/user-function hooks only gate on _tracing_enabled, this leaves the plugin in a half-enabled state for the rest of the invocation, contradicting the "telemetry is disabled for this invocation" intent. See the two inline comments:

  • packages/aws-durable-execution-sdk-python-otel/src/aws_durable_execution_sdk_python_otel/invocation_plugin.py:463
  • packages/aws-durable-execution-sdk-python-otel/src/aws_durable_execution_sdk_python_otel/execution_plugin.py:340

Residual test risk: the new test_invocation_start_without_execution_arn_disables_tracing tests (in both plugins) only drive on_invocation_start/on_invocation_end, so they don't exercise the operation hooks and don't catch the stale-_tracing_enabled behavior. Adding a case that fires on_operation_start/on_user_function_start after a no-ARN start would guard this path.

Reviewed commit 9ff9f5561b298221fbb08b9620043fb7a2cbb7a7. Workflow run

@ayushiahjolia
ayushiahjolia force-pushed the otel-shared-execution-trace branch from 9ff9f55 to b645aea Compare August 27, 2026 05:06
@ayushiahjolia
ayushiahjolia deployed to ai-pr-review-runtime August 27, 2026 05:08 — with GitHub Actions Active
Comment on lines +105 to +118
if isinstance(extracted, Context):
span_context = trace.get_current_span(extracted).get_span_context()
if not span_context.is_valid:
return None
sampling = (
Sampling.SAMPLED
if bool(span_context.trace_flags & trace.TraceFlags.SAMPLED)
else Sampling.NOT_SAMPLED
)
return ExtractedContext(
trace_id=span_context.trace_id,
parent_span_id=span_context.span_id,
sampling=sampling,
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex AI review

P2: This compatibility path discards everything in the legacy Context except IDs and sampled flags. Baggage, custom context keys, and trace_state previously reached parent span creation and samplers; a recording-but-unsampled span is also converted into authoritative NOT_SAMPLED, causing durable spans to be dropped. Preserve the original context metadata and recording decision through parent construction and sampling resolution, or treat legacy contexts as a versioned breaking change instead of silently normalizing them.

Comment on lines +493 to +497
self._execution_trace_id = canonical_trace_id(
extracted=self._extracted_context,
execution_arn=self._execution_arn,
execution_start_time=info.execution_start_time,
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex AI review

P2: Making the backend X-Ray root authoritative is cross-component, cross-invocation behavior, but the PR adds only in-process tests with fabricated headers and exporters. It does not verify that real durable wait/resume invocations and ADOT propagation produce one stable trace. Repository policy requires an e2e test for this public workflow change; add one under tests/e2e/ covering at least two invocations and asserting Workflow, Invocation, and operation trace IDs and parentage. Coordinate any separate conformance requirement rather than modifying conformance tests here.

@github-actions

Copy link
Copy Markdown
Contributor

Codex AI review

Found two medium-severity issues affecting context compatibility and required end-to-end coverage.

Reviewed commit b645aead6be02a0fdb1165d4a1ff11c0af2685b5. Workflow run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant