Skip to content

Commit 8ebd9fb

Browse files
Copilotpelikhan
andauthored
Finalize eval OTLP reporting
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
1 parent ce2fdf5 commit 8ebd9fb

1 file changed

Lines changed: 16 additions & 14 deletions

File tree

actions/setup/js/send_otlp_span.cjs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ function buildGraderTelemetry(graderOutput, eventTimeMs) {
758758
* Build summary attributes and per-result events from BinEval JSONL records.
759759
* Only bounded, structured fields are included; free-form questions are excluded.
760760
*
761-
* @param {unknown[]} evalResults
761+
* @param {any[]} evalResults
762762
* @param {number} eventTimeMs
763763
* @returns {{attributes: Array<{key: string, value: object}>, events: Array<{timeUnixNano: string, name: string, attributes: Array<{key: string, value: object}>}>}}
764764
*/
@@ -1531,6 +1531,20 @@ function readJSONIfExists(filePath) {
15311531
}
15321532
}
15331533

1534+
/**
1535+
* Safely read and parse a JSONL file. Returns an empty array on any error.
1536+
*
1537+
* @param {string} filePath - Absolute path to the JSONL file
1538+
* @returns {any[]}
1539+
*/
1540+
function readJSONLIfExists(filePath) {
1541+
try {
1542+
return parseJsonlContent(fs.readFileSync(filePath, "utf8"));
1543+
} catch {
1544+
return [];
1545+
}
1546+
}
1547+
15341548
/**
15351549
* Path to the GitHub rate-limit JSONL log file.
15361550
* Mirrors GITHUB_RATE_LIMITS_JSONL_PATH from constants.cjs without introducing
@@ -2411,19 +2425,7 @@ async function sendJobConclusionSpan(spanName, options = {}) {
24112425
}
24122426

24132427
const graderTelemetry = jobName === "agent" ? buildGraderTelemetry(readJSONIfExists("/tmp/gh-aw/agent/graders/grader_results.json"), endMs) : { attributes: [], events: [] };
2414-
const evalTelemetry =
2415-
jobName === "evals"
2416-
? buildEvalTelemetry(
2417-
(() => {
2418-
try {
2419-
return parseJsonlContent(fs.readFileSync("/tmp/gh-aw/evals.jsonl", "utf8"));
2420-
} catch {
2421-
return [];
2422-
}
2423-
})(),
2424-
endMs
2425-
)
2426-
: { attributes: [], events: [] };
2428+
const evalTelemetry = jobName === "evals" ? buildEvalTelemetry(readJSONLIfExists("/tmp/gh-aw/evals.jsonl"), endMs) : { attributes: [], events: [] };
24272429

24282430
const resourceAttributes = buildGitHubActionsResourceAttributes({
24292431
repository,

0 commit comments

Comments
 (0)