Skip to content

feat(otel): propagate parent span ID through aw_context for cross-job trace hierarchy#25540

Merged
pelikhan merged 2 commits intomainfrom
copilot/otel-improvement-propagate-parent-span-id
Apr 9, 2026
Merged

feat(otel): propagate parent span ID through aw_context for cross-job trace hierarchy#25540
pelikhan merged 2 commits intomainfrom
copilot/otel-improvement-propagate-parent-span-id

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 9, 2026

Child workflow setup spans were sent with no parentSpanId, causing multi-job dispatch traces to appear as disconnected root spans in every OTel backend instead of a properly nested tree.

Changes

  • aw_context.cjsbuildAwContext() now includes otel_parent_span_id from GITHUB_AW_OTEL_PARENT_SPAN_ID, mirroring the existing otel_trace_id / GITHUB_AW_OTEL_TRACE_ID propagation
  • send_otlp_span.cjssendJobSetupSpan reads awInfo.context.otel_parent_span_id and passes it as parentSpanId to buildOTLPPayload, linking the child setup span under the parent's setup span
  • send_otlp_span.test.cjs — three new tests covering valid propagation, absent field, and invalid span ID rejection

Result

Child job setup spans in dispatched workflows now carry the parent job's span ID:

// Before: child setup span is a disconnected root
{ traceId: "<parent_trace_id>", spanId: "<child_span_id>" }

// After: child setup span is properly nested
{ traceId: "<parent_trace_id>", spanId: "<child_span_id>", parentSpanId: "<parent_span_id>" }

…trace hierarchy (#issue)

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/5f39e758-51a4-4d6f-a422-546b4acd439e

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve OTel propagation of parent span ID through aw_context feat(otel): propagate parent span ID through aw_context for cross-job trace hierarchy Apr 9, 2026
Copilot AI requested a review from pelikhan April 9, 2026 22:14
@pelikhan pelikhan marked this pull request as ready for review April 9, 2026 22:26
Copilot AI review requested due to automatic review settings April 9, 2026 22:26
@pelikhan pelikhan merged commit d143188 into main Apr 9, 2026
5 checks passed
@pelikhan pelikhan deleted the copilot/otel-improvement-propagate-parent-span-id branch April 9, 2026 22:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes cross-workflow trace hierarchy in OTLP by propagating the parent job’s setup span ID through aw_context and using it as parentSpanId for dispatched child workflow setup spans, so traces render as a single nested tree instead of disconnected roots.

Changes:

  • Add otel_parent_span_id to aw_context (sourced from GITHUB_AW_OTEL_PARENT_SPAN_ID) to propagate the parent setup span across workflow dispatch boundaries.
  • Update sendJobSetupSpan to read aw_info.context.otel_parent_span_id, validate it, and pass it to buildOTLPPayload as parentSpanId.
  • Add tests to verify valid propagation, omission when absent, and omission when invalid.
Show a summary per file
File Description
actions/setup/js/aw_context.cjs Extends dispatched aw_context with otel_parent_span_id to carry parent setup span ID to child workflows.
actions/setup/js/send_otlp_span.cjs Uses propagated otel_parent_span_id (when valid) as parentSpanId on the child job setup span payload.
actions/setup/js/send_otlp_span.test.cjs Adds coverage for propagation/absence/invalid cases for otel_parent_span_idparentSpanId.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 0

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.

[otel-advisor] OTel improvement: propagate parent span ID through aw_context for proper cross-job trace hierarchy

3 participants