Skip to content

fix(otel): show real OTLP trace ID in observability job summary#24666

Merged
pelikhan merged 2 commits intomainfrom
copilot/otel-advisor-fix-observability-summary
Apr 5, 2026
Merged

fix(otel): show real OTLP trace ID in observability job summary#24666
pelikhan merged 2 commits intomainfrom
copilot/otel-advisor-fix-observability-summary

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 5, 2026

The observability job summary was displaying workflow_call_id (e.g. 12345678901-1) as the trace ID — a value that doesn't exist in any observability backend — instead of the actual 32-char hex OTLP trace ID stored in otel_trace_id.

Changes

  • generate_observability_summary.cjs: collectObservabilityData() now prefers otel_trace_id over workflow_call_id, falling back to workflow_call_id only when absent:

    // Before
    const traceId = awInfo.context && typeof awInfo.context.workflow_call_id === "string"
      ? awInfo.context.workflow_call_id   // ❌ "12345678901-1"
      : "";
    
    // After
    const traceId = awInfo.context
      ? awInfo.context.otel_trace_id || awInfo.context.workflow_call_id || ""
      : "";                               // ✅ "a3f2c8d1e4b7091f6a5c2e3d8f401b72"
  • generate_observability_summary.test.cjs: Updated existing fixture to include both fields and assert otel_trace_id wins; added a fallback test asserting workflow_call_id is used when otel_trace_id is absent.

Prefer `otel_trace_id` over `workflow_call_id` in
`collectObservabilityData()` so the job summary displays the 32-char
hex trace ID that exists in Sentry/Honeycomb/Datadog, with a fallback
to `workflow_call_id` when the OTLP trace ID is not available.

Updated tests to assert the correct field is used and added a fallback
test case.

Fixes #<issue>

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/da3f4dd1-cc9a-45d9-800b-988d0fd3bb8d

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix observability summary to show real OTLP trace ID fix(otel): show real OTLP trace ID in observability job summary Apr 5, 2026
Copilot AI requested a review from pelikhan April 5, 2026 04:39
@pelikhan pelikhan marked this pull request as ready for review April 5, 2026 04:40
Copilot AI review requested due to automatic review settings April 5, 2026 04:40
@pelikhan pelikhan merged commit e4fdbe3 into main Apr 5, 2026
51 checks passed
@pelikhan pelikhan deleted the copilot/otel-advisor-fix-observability-summary branch April 5, 2026 04:40
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

Fixes the observability job summary to display a real OTLP trace ID (from otel_trace_id) instead of the synthetic workflow_call_id, improving trace lookup in observability backends.

Changes:

  • Update summary data collection to prefer context.otel_trace_id, falling back to context.workflow_call_id.
  • Update/add tests to assert preference behavior and fallback behavior.
Show a summary per file
File Description
actions/setup/js/generate_observability_summary.cjs Prefer otel_trace_id over workflow_call_id when populating the trace ID shown in the job summary.
actions/setup/js/generate_observability_summary.test.cjs Expand fixtures/assertions to verify otel_trace_id wins and that workflow_call_id is used as a fallback.

Copilot's findings

Tip

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

  • Files reviewed: 2/2 changed files
  • Comments generated: 1

const items = Array.isArray(agentOutput.items) ? agentOutput.items : [];
const errors = Array.isArray(agentOutput.errors) ? agentOutput.errors : [];
const traceId = awInfo.context && typeof awInfo.context.workflow_call_id === "string" ? awInfo.context.workflow_call_id : "";
const traceId = awInfo.context ? awInfo.context.otel_trace_id || awInfo.context.workflow_call_id || "" : "";
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

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

traceId selection no longer verifies that otel_trace_id / workflow_call_id are strings (and, for otel_trace_id, a valid 32-hex OTLP trace ID). If otel_trace_id is present but invalid (wrong length / non-hex / non-string), the summary will still display it and will not fall back, potentially showing a value that cannot be searched in backends. Consider normalizing (trim().toLowerCase()), validating (e.g. /^[0-9a-f]{32}$/), and only preferring otel_trace_id when valid; otherwise fall back to a string workflow_call_id (matching the previous type-guard behavior).

See below for a potential fix:

function normalizeString(value) {
  return typeof value === "string" ? value.trim() : "";
}

function normalizeOtelTraceId(value) {
  const normalized = normalizeString(value).toLowerCase();
  return /^[0-9a-f]{32}$/.test(normalized) ? normalized : "";
}

function selectTraceId(context) {
  if (!context) {
    return "";
  }

  const otelTraceId = normalizeOtelTraceId(context.otel_trace_id);
  if (otelTraceId) {
    return otelTraceId;
  }

  return normalizeString(context.workflow_call_id);
}

function collectObservabilityData() {
  const awInfo = readJSONIfExists(AW_INFO_PATH) || {};
  const agentOutput = readJSONIfExists(AGENT_OUTPUT_PATH) || { items: [], errors: [] };
  const items = Array.isArray(agentOutput.items) ? agentOutput.items : [];
  const errors = Array.isArray(agentOutput.errors) ? agentOutput.errors : [];
  const traceId = selectTraceId(awInfo.context);

Copilot uses AI. Check for mistakes.
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: fix observability summary to show the real OTLP trace ID instead of workflow_call_id

3 participants