Skip to content

Propagate GH_AW_INFO_ENGINE_ID into setup steps so setup OTel spans emit gh-aw.engine.id#32298

Closed
Copilot wants to merge 4 commits into
mainfrom
copilot/grafana-otel-advisor-propagate-gh-aw-engine-id
Closed

Propagate GH_AW_INFO_ENGINE_ID into setup steps so setup OTel spans emit gh-aw.engine.id#32298
Copilot wants to merge 4 commits into
mainfrom
copilot/grafana-otel-advisor-propagate-gh-aw-engine-id

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 15, 2026

Bug Fix

gh-aw.<job>.setup spans were missing gh-aw.engine.id because setup runs before aw_info.json exists and setup steps did not receive GH_AW_INFO_ENGINE_ID. This blocked engine-segmented setup observability (e.g., p95 setup latency and pre-agent failure rate by engine).

What was the bug?

  • Setup span emission (sendJobSetupSpan) already supports GH_AW_INFO_ENGINE_ID, but compiled setup steps did not inject that env var.
  • Result: setup spans were unlabeled by engine, while later spans had engine context.

How did you fix it?

  • Setup-step engine env propagation

    • Added getEngineIDForSetup(data *WorkflowData) to resolve engine ID from:
      • EngineConfig.ID (preferred)
      • legacy AI field (fallback)
    • Injected GH_AW_INFO_ENGINE_ID into generated Setup Scripts step env in:
      • action mode (uses: ./actions/setup)
      • script mode (bash .../setup.sh)
  • Compiler/output alignment

    • Updated setup-step generation to include engine ID only when non-empty.
    • Updated affected wasm compile goldens to reflect setup env output changes.
  • Focused coverage

    • Added setup-step tests for engine ID injection in both action and script modes.
- name: Setup Scripts
  env:
    GH_AW_SETUP_WORKFLOW_NAME: "..."
    GH_AW_CURRENT_WORKFLOW_REF: ${{ github.repository }}/.github/workflows/....lock.yml@${{ github.ref }}
    GH_AW_INFO_ENGINE_ID: "copilot"

Testing

  • Added targeted compiler tests asserting GH_AW_INFO_ENGINE_ID is emitted in setup steps (action + script modes), and refreshed corresponding wasm golden outputs.

Copilot AI changed the title [WIP] Improve OTel instrumentation to propagate gh-aw.engine.id to setup spans Propagate GH_AW_INFO_ENGINE_ID into setup steps so setup OTel spans emit gh-aw.engine.id May 15, 2026
Copilot AI requested a review from pelikhan May 15, 2026 06:05
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot read engine is from merged frontmatter

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 15, 2026

@copilot read engine is from merged frontmatter

Updated in 4cfe855: setup-step engine ID resolution now reads from RawFrontmatter["engine"] first (string, engine.id, or engine.runtime.id), then falls back to merged engine fields (EngineConfig.ID / AI). Added focused tests in setup_step_version_test.go.

@pelikhan pelikhan marked this pull request as ready for review May 15, 2026 12:02
Copilot AI review requested due to automatic review settings May 15, 2026 12:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes missing gh-aw.engine.id attribution on gh-aw.<job>.setup OpenTelemetry spans by propagating GH_AW_INFO_ENGINE_ID into the generated “Setup Scripts” step environment (both action-mode and script-mode), and refreshes goldens/lockfiles accordingly.

Changes:

  • Inject GH_AW_INFO_ENGINE_ID into generated setup-step env: when a non-empty engine ID can be resolved.
  • Add getEngineIDForSetup(*WorkflowData) helper for setup-step engine ID resolution.
  • Update wasm compile goldens and workflow .lock.yml outputs to reflect the new setup-step env var.
Show a summary per file
File Description
pkg/workflow/compiler_yaml_step_generation.go Injects GH_AW_INFO_ENGINE_ID into setup-step env for script + action modes.
pkg/workflow/compiler_yaml_lookups.go Adds getEngineIDForSetup helper used by setup-step generation.
pkg/workflow/testdata/TestWasmGolden_CompileFixtures/with-imports.golden Updates golden to include GH_AW_INFO_ENGINE_ID in setup-step env.
pkg/workflow/testdata/TestWasmGolden_CompileFixtures/smoke-copilot.golden Updates golden to include GH_AW_INFO_ENGINE_ID in setup-step env.
pkg/workflow/testdata/TestWasmGolden_CompileFixtures/playwright-cli-mode.golden Updates golden to include GH_AW_INFO_ENGINE_ID in setup-step env.
pkg/workflow/testdata/TestWasmGolden_CompileFixtures/basic-copilot.golden Updates golden to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/workflow-skill-extractor.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/workflow-normalizer.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/weekly-safe-outputs-spec-review.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/visual-regression-checker.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/video-analyzer.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/update-astro.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/ubuntu-image-analyzer.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/typist.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/tidy.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/test-workflow.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/test-quality-sentinel.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/test-project-url-default.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/test-dispatcher.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/terminal-stylist.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/super-linter.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/sub-issue-closer.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/step-name-alignment.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/static-analysis-report.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/stale-pr-cleanup.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/spec-librarian.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/spec-extractor.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/spec-enforcer.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/smoke-test-tools.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/smoke-project.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/smoke-otel.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/smoke-opencode.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/smoke-crush.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/semantic-function-refactor.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/security-review.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/security-compliance.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/schema-consistency-checker.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/safe-output-health.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/research.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/repo-tree-map.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/release.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/refiner.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/q.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/pr-sous-chef.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/pr-code-quality-reviewer.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/plan.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/outcome-collector.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/notion-issue-summary.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/mergefest.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/mcp-inspector.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/linter-miner.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/layout-spec-maintainer.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/jsweep.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/issue-triage-agent.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/issue-monster.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/instructions-janitor.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/hourly-ci-cleaner.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/hippo-embed.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/gpclean.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/go-pattern-detector.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/go-logger.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/go-fan.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/github-remote-mcp-auth-test.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/functional-pragmatist.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/firewall.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/example-workflow-analyzer.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/example-permissions-warning.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/draft-pr-cleanup.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/dictation-prompt.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/dev.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/dev-hawk.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/deployment-incident-monitor.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/dependabot-go-checker.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/dependabot-campaign.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/dependabot-burner.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/delight.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-workflow-updater.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-token-consumption-report.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-team-status.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-team-evolution-insights.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-syntax-error-quality.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-skill-optimizer.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-semgrep-scan.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-secrets-analysis.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-safe-outputs-conformance.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-safe-output-integrator.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-regulatory.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-otel-instrumentation-advisor.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-multi-device-docs-tester.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-model-inventory.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-malicious-code-scan.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-grafana-otel-instrumentation-advisor.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-geo-optimizer.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-file-diet.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-doc-updater.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-doc-healer.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-compiler-threat-spec-optimizer.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-compiler-quality.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-cli-tools-tester.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-choice-test.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-assign-issue-to-user.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/daily-agentrx-trace-optimizer.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/craft.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/copilot-token-optimizer.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/copilot-opt.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/contribution-check.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/commit-changes-analyzer.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/codex-github-remote-mcp-test.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/code-simplifier.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/cli-version-checker.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/cli-consistency-checker.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/ci-coach.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/changeset.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/brave.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/bot-detection.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/blog-auditor.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/aw-portfolio-yield.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/aw-failure-investigator.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/artifacts-summary.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/architecture-guardian.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/archie.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/approach-validator.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/ai-moderator.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.
.github/workflows/ace-editor.lock.yml Regenerated lock output to include GH_AW_INFO_ENGINE_ID in setup-step env.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comments suppressed due to low confidence (1)

pkg/workflow/compiler_yaml_lookups.go:69

  • In getEngineIDForSetup, the engine raw-frontmatter paths return immediately even if the trimmed value is empty/whitespace (e.g., engine: "" or engine.runtime.id: ""). That prevents the function from falling back to EngineConfig.ID/AI and can silently drop GH_AW_INFO_ENGINE_ID injection. Consider only returning the raw-frontmatter value when strings.TrimSpace(...) != ""; otherwise continue to the fallback logic.
  • Files reviewed: 236/236 changed files
  • Comments generated: 1

Comment on lines +51 to +57
// getEngineIDForSetup returns the engine ID to inject into setup-step env.
// Prefer EngineConfig.ID and fall back to the legacy AI field.
func getEngineIDForSetup(data *WorkflowData) string {
if data == nil {
return ""
}
if engineRaw, ok := data.RawFrontmatter["engine"]; ok {
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot merge main and recompile

@pelikhan pelikhan closed this May 15, 2026
Copilot stopped work on behalf of pelikhan due to an error May 15, 2026 12:23
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.

[grafana-otel-advisor] OTel improvement: propagate gh-aw.engine.id to all setup spans

3 participants