Skip to content

fix: usage tracking for engine jobs in sendJobConclusionSpan#38353

Merged
mnkiefer merged 1 commit into
mainfrom
fix-aic-stream
Jun 10, 2026
Merged

fix: usage tracking for engine jobs in sendJobConclusionSpan#38353
mnkiefer merged 1 commit into
mainfrom
fix-aic-stream

Conversation

@mnkiefer

@mnkiefer mnkiefer commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

fix: usage tracking for engine jobs in sendJobConclusionSpan

Summary

Fixes a gap in OTLP token-usage and AI-credit reporting where custom-engine jobs were silently skipped. jobEmitsOwnTokenUsage previously did not recognise jobs whose name is the engine ID itself, so those jobs never emitted token-breakdown or gh-aw.aic attributes in their conclusion spans.

What changed

File Kind Description
actions/setup/js/send_otlp_span.cjs fix Extends jobEmitsOwnTokenUsage to also match jobs whose INPUT_JOB_NAME equals GH_AW_INFO_ENGINE_ID; updates two associated comments to reflect the broader matching scope.
actions/setup/js/send_otlp_span.test.cjs test Adds a test asserting that when the job name equals the engine ID, sendJobConclusionSpan correctly emits token-breakdown and gh-aw.aic cost attributes.

Note: Both files are generated/bundled artifacts (*.cjs). The diff stat is empty for this reason; the logical change lives in the bundled output.

Why

Custom-engine jobs set INPUT_JOB_NAME to the engine ID. Without the additional equality check, jobEmitsOwnTokenUsage returned false for those jobs, suppressing their usage spans entirely. This caused gaps in per-job cost and token telemetry for engine-named jobs.

How

The jobEmitsOwnTokenUsage predicate is broadened with an || jobName === engineId branch. No change to the span schema itself; token-breakdown and AI-credit attributes were already supported — they just weren't being attached.

Risk

Low. The change is additive (new match branch, not a replacement). The new test provides direct coverage. No breaking changes to the OTLP span format or downstream consumers.

Generated by PR Description Updater for issue #38353 · 96.1 AIC · ⌖ 12.4 AIC · ⊞ 19.8K ·

@mnkiefer mnkiefer self-assigned this Jun 10, 2026
Copilot AI review requested due to automatic review settings June 10, 2026 12:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 token-usage telemetry attribution for “engine jobs” in sendJobConclusionSpan by treating jobs whose INPUT_JOB_NAME matches the resolved engine ID (e.g., copilot) as the rightful emitter of gen_ai.usage.* and gh-aw.aic attributes, preventing downstream jobs from double-emitting usage data.

Changes:

  • Extend jobEmitsOwnTokenUsage to include engine jobs where jobName === engineId.
  • Clarify comments around why token usage and AI credit attributes must be gated.
  • Add a unit test asserting that an engine job emits token breakdown + cost attributes when job name matches engine ID.
Show a summary per file
File Description
actions/setup/js/send_otlp_span.cjs Updates token-usage ownership logic to include engine jobs and keeps usage emission gated to avoid downstream double-counting.
actions/setup/js/send_otlp_span.test.cjs Adds coverage verifying engine-job spans emit gen_ai.usage.* and gh-aw.aic when INPUT_JOB_NAME matches the engine ID.

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: 0

@mnkiefer mnkiefer merged commit 98fcb27 into main Jun 10, 2026
25 checks passed
@mnkiefer mnkiefer deleted the fix-aic-stream branch June 10, 2026 12:14
@github-actions

Copy link
Copy Markdown
Contributor

✅ smoke-ci: safeoutputs CLI comment + comment-memory run (27275233892)

Generated by 🧪 Smoke CI for issue #38353 ·

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

CI lights the path
Green checks bloom at dawn
Quiet bots still sing

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

Generated by 🧪 Smoke CI for issue #38353 ·

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.

2 participants