Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions actions/setup/js/send_otlp_span.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { randomBytes } = require("crypto");
const fs = require("fs");
const { nowMs } = require("./performance_now.cjs");
const { buildWorkflowRunUrl } = require("./workflow_metadata_helpers.cjs");
const { getErrorMessage } = require("./error_helpers.cjs");

/**
* send_otlp_span.cjs
Expand Down Expand Up @@ -709,10 +710,7 @@ async function sendJobConclusionSpan(spanName, options = {}) {
const agentOutput = readJSONIfExists("/tmp/gh-aw/agent_output.json") || {};
const outputErrors = Array.isArray(agentOutput.errors) ? agentOutput.errors : [];
const outputItems = Array.isArray(agentOutput.items) ? agentOutput.items : [];
const errorMessages = outputErrors
.map(e => (e && typeof e.message === "string" ? e.message : String(e)))
.filter(Boolean)
.slice(0, 5);
const errorMessages = outputErrors.map(getErrorMessage).filter(Boolean).slice(0, 5);

if (isAgentFailure && errorMessages.length > 0) {
statusMessage = `agent ${agentConclusion}: ${errorMessages[0]}`.slice(0, 256);
Expand Down Expand Up @@ -755,7 +753,8 @@ async function sendJobConclusionSpan(spanName, options = {}) {
attributes.push(buildAttr("gh-aw.error.messages", errorMessages.join(" | ")));
}
attributes.push(buildAttr("gh-aw.output.item_count", outputItems.length));
const itemTypes = [...new Set(outputItems.map(i => (i && typeof i.type === "string" ? i.type : "")).filter(Boolean))].sort();
const rawItemTypes = outputItems.map(i => (i && typeof i.type === "string" ? i.type : "")).filter(Boolean);
const itemTypes = [...new Set(rawItemTypes)].sort();
if (itemTypes.length > 0) {
attributes.push(buildAttr("gh-aw.output.item_types", itemTypes.join(",")));
}
Expand Down Expand Up @@ -810,7 +809,7 @@ async function sendJobConclusionSpan(spanName, options = {}) {
}
const errorTimeNano = toNanoString(eventTimeMs);
return outputErrors
.map(e => (e && typeof e.message === "string" ? e.message : String(e)))
.map(getErrorMessage)
.filter(Boolean)
.map(msg => {
// Extract colon-prefixed type when available ("push_to_pull_request_branch:...")
Expand Down