Skip to content

Ensure gh-aw.aic is emitted on conclusion spans when INPUT_JOB_NAME is missing#38510

Merged
mnkiefer merged 3 commits into
mainfrom
copilot/token-consumption-daily-aic-report
Jun 11, 2026
Merged

Ensure gh-aw.aic is emitted on conclusion spans when INPUT_JOB_NAME is missing#38510
mnkiefer merged 3 commits into
mainfrom
copilot/token-consumption-daily-aic-report

Conversation

Copilot AI commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

The daily AIC report showed an observability gap: AIC could not be queried in Sentry/Tempo even though OTLP spans were flowing. The missing signal came from conclusion spans that skipped AIC emission when INPUT_JOB_NAME was absent in some post-step execution paths.

  • Root cause addressed

    • sendJobConclusionSpan gated AIC emission on jobEmitsOwnTokenUsage, which depended only on INPUT_JOB_NAME.
    • In environments where post-step env propagation dropped INPUT_JOB_NAME, spans like gh-aw.agent.conclusion did not emit gh-aw.aic.
  • Implementation change

    • Added resolveConclusionJobName(spanName) in actions/setup/js/send_otlp_span.cjs.
    • Job name resolution now uses:
      1. INPUT_JOB_NAME when present
      2. fallback parse from span name pattern gh-aw.<job>.conclusion
    • sendJobConclusionSpan now uses this resolver before computing jobEmitsOwnTokenUsage.
  • Coverage update

    • Added regression test in actions/setup/js/send_otlp_span.test.cjs for:
      • missing INPUT_JOB_NAME
      • span name gh-aw.agent.conclusion
      • expected numeric gh-aw.aic emission from GH_AW_AIC.
function resolveConclusionJobName(spanName) {
  const inputJobName = (process.env.INPUT_JOB_NAME || "").trim();
  if (inputJobName) return inputJobName;
  const match = /^gh-aw\.([^.]+)\.conclusion$/.exec(spanName);
  return match ? match[1] : "";
}

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix AIC consumption metric reporting issue Ensure gh-aw.aic is emitted on conclusion spans when INPUT_JOB_NAME is missing Jun 11, 2026
Copilot AI requested a review from mnkiefer June 11, 2026 06:06
@pelikhan pelikhan marked this pull request as ready for review June 11, 2026 06:25
Copilot AI review requested due to automatic review settings June 11, 2026 06:25

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 an observability gap where conclusion spans could skip emitting the numeric gh-aw.aic attribute when INPUT_JOB_NAME was not present in certain post-step execution paths, preventing reliable querying/aggregation in Sentry/Tempo.

Changes:

  • Added resolveConclusionJobName(spanName) to derive the job name from INPUT_JOB_NAME, or fall back to parsing gh-aw.<job>.conclusion.
  • Updated sendJobConclusionSpan to use the resolved job name before computing jobEmitsOwnTokenUsage (restoring gh-aw.aic emission for affected conclusion spans).
  • Added a regression test covering missing INPUT_JOB_NAME with span name gh-aw.agent.conclusion and verifying numeric gh-aw.aic emission from GH_AW_AIC.
Show a summary per file
File Description
actions/setup/js/send_otlp_span.cjs Adds job-name resolution fallback for conclusion spans to ensure gh-aw.aic is emitted when INPUT_JOB_NAME is missing.
actions/setup/js/send_otlp_span.test.cjs Adds a regression test verifying gh-aw.aic is included when INPUT_JOB_NAME is absent but the span name identifies the job.

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

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.

[token-consumption] Daily AIC Consumption Report - 2026-06-11

4 participants