fix(otel): show real OTLP trace ID in observability job summary#24666
fix(otel): show real OTLP trace ID in observability job summary#24666
Conversation
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>
There was a problem hiding this comment.
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 tocontext.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 || "" : ""; |
There was a problem hiding this comment.
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);
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 inotel_trace_id.Changes
generate_observability_summary.cjs:collectObservabilityData()now prefersotel_trace_idoverworkflow_call_id, falling back toworkflow_call_idonly when absent:generate_observability_summary.test.cjs: Updated existing fixture to include both fields and assertotel_trace_idwins; added a fallback test assertingworkflow_call_idis used whenotel_trace_idis absent.