Skip to content

feat(otel): parent durable spans to shared trace - #693

Merged
ayushiahjolia merged 1 commit into
mainfrom
otel-shared-trace-pr3-plugins
Sep 1, 2026
Merged

feat(otel): parent durable spans to shared trace#693
ayushiahjolia merged 1 commit into
mainfrom
otel-shared-trace-pr3-plugins

Conversation

@ayushiahjolia

Copy link
Copy Markdown
Contributor

Issue #, if available: #674

Description of changes:

  • Third PR in the stack for reparenting durable OTel spans onto one shared execution trace.
  • Wires both plugins (InvocationOtelPlugin and ExecutionOtelPlugin) onto the shared execution trace and sampling. Workflow and Invocation spans now share one trace, anchored to a propagated backend parent when present or a deterministic synthetic execution root otherwise; an ambient Lambda span is used as parent only when it already belongs to the execution trace.
  • Sampling is resolved once per invocation and applied to every durable span. Also completes the context_extractors rewrite deferred from the first PR: extractors now return a structured ExtractedContext instead of an opaque OTel Context.
  • Next in stack: docs (README) update for the shared-trace model.

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

@ayushiahjolia

Copy link
Copy Markdown
Contributor Author

/ai review

@ayushiahjolia
ayushiahjolia marked this pull request as ready for review August 31, 2026 18:26
@ayushiahjolia
ayushiahjolia temporarily deployed to ai-pr-review-runtime August 31, 2026 18:26 — with GitHub Actions Inactive
zhongkechen
zhongkechen previously approved these changes Sep 1, 2026
Base automatically changed from otel-shared-trace-pr2-sampling to main September 1, 2026 18:37
@ayushiahjolia
ayushiahjolia temporarily deployed to ai-pr-review-runtime September 1, 2026 19:14 — with GitHub Actions Inactive
@ayushiahjolia
ayushiahjolia merged commit ee22f2b into main Sep 1, 2026
13 of 42 checks passed
@ayushiahjolia
ayushiahjolia deleted the otel-shared-trace-pr3-plugins branch September 1, 2026 19:42
Comment on lines +53 to +61
ContextExtractor = Callable[["InvocationStartInfo"], ExtractedContext | None]


def _ensure_extracted_context(extracted: object) -> ExtractedContext | None:
"""Validate a context extractor result."""
if extracted is None or isinstance(extracted, ExtractedContext):
return extracted
msg = "context extractor must return ExtractedContext or None"
raise TypeError(msg)

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 · Finding arf_v1_jmtbmucp2dm4ijijefd7jx7nco

[P1] Preserve the existing ContextExtractor contract. This public type previously returned an OpenTelemetry Context, so existing custom extractors now raise TypeError on every invocation and produce no telemetry. Support legacy Context results through an adapter/deprecation period (extracting their active SpanContext), or introduce a separate new configuration API, and retain a regression test using lambda _: Context().

after_resume = next(span for span in spans if span.name == "otel-after-resume")

assert len(invocations) >= 2
assert len(waits) >= 2

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 · Finding arf_v1_vawkqcby4mibdv6padk3raorfm

[P1] Account for the execution-view plugin's suspended-span behavior. ExecutionOtelPlugin.on_invocation_end deliberately leaves the first invocation's pending wait span unended and unexported, so only the resumed continuation is present and len(waits) is 1. This parametrized test therefore fails for ExecutionOtelPlugin; use plugin-specific minimum counts or change that plugin's lifecycle semantics consistently.

Suggested change
assert len(waits) >= 2
minimum_wait_count = 2 if plugin_type is InvocationOtelPlugin else 1
assert len(waits) >= minimum_wait_count

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Codex AI review

Two blocking issues remain: a public context-extractor compatibility break and an E2E assertion that fails for ExecutionOtelPlugin.

Reviewed commit aec6acfa2bc32257c2d86726b380713f1cbc0d8d. 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.

2 participants