Skip to content

Emit engine metadata on setup spans by injecting GH_AW_INFO_ENGINE_ID into Setup Scripts env#32634

Merged
pelikhan merged 3 commits into
mainfrom
copilot/grafana-otel-advisor-improve-otel-setup
May 16, 2026
Merged

Emit engine metadata on setup spans by injecting GH_AW_INFO_ENGINE_ID into Setup Scripts env#32634
pelikhan merged 3 commits into
mainfrom
copilot/grafana-otel-advisor-improve-otel-setup

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 16, 2026

gh-aw.<job>.setup spans were missing gh-aw.engine.id / gen_ai.system because setup runs before generate_aw_info, so /tmp/gh-aw/aw_info.json is not yet available at setup span emission time. This prevented direct setup-latency slicing by engine from a single span.

  • Compiler change: make engine ID available at setup time

    • Updated setup-step generation to emit GH_AW_INFO_ENGINE_ID in Setup Scripts env.
    • Applied in both setup paths:
      • script mode (run: bash .../setup.sh)
      • action mode (uses: .../actions/setup)
    • Engine resolution mirrors existing precedence:
      • engine-config.id first
      • fallback to ai
  • Targeted coverage for setup-step env generation

    • Added focused tests asserting GH_AW_INFO_ENGINE_ID is present in generated setup steps:
      • from EngineConfig.ID
      • from AI in script mode
  • Golden updates

    • Updated wasm compile golden fixtures impacted by the new setup env line.
- name: Setup Scripts
  env:
    GH_AW_SETUP_WORKFLOW_NAME: "..."
    GH_AW_CURRENT_WORKFLOW_REF: ${{ ... }}
    GH_AW_INFO_ENGINE_ID: "copilot"

This ensures sendJobSetupSpan can resolve engine ID during setup and emit both gh-aw.engine.id and gen_ai.system on the setup span.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve OTel instrumentation to emit engine ID and system attributes Emit engine metadata on setup spans by injecting GH_AW_INFO_ENGINE_ID into Setup Scripts env May 16, 2026
Copilot AI requested a review from pelikhan May 16, 2026 14:46
@pelikhan pelikhan marked this pull request as ready for review May 16, 2026 14:52
Copilot AI review requested due to automatic review settings May 16, 2026 14:52
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

This pull request ensures gh-aw.<job>.setup spans can emit gh-aw.engine.id / gen_ai.system by making the engine ID available during the setup step (before aw_info.json is generated).

Changes:

  • Inject GH_AW_INFO_ENGINE_ID into the Setup Scripts step env in both action and script setup paths, using precedence EngineConfig.IDAI.
  • Add unit tests covering engine ID env injection for action mode (from EngineConfig.ID) and script mode (from AI).
  • Update wasm compile golden fixtures to include the new setup-step env line.
Show a summary per file
File Description
pkg/workflow/compiler_yaml_step_generation.go Adds engine ID resolution and injects GH_AW_INFO_ENGINE_ID into setup-step env for script + action modes.
pkg/workflow/setup_step_version_test.go Adds focused tests asserting GH_AW_INFO_ENGINE_ID is present in generated setup steps.
pkg/workflow/testdata/TestWasmGolden_CompileFixtures/with-imports.golden Golden update to include GH_AW_INFO_ENGINE_ID on setup steps.
pkg/workflow/testdata/TestWasmGolden_CompileFixtures/smoke-copilot.golden Golden update to include GH_AW_INFO_ENGINE_ID on setup steps.
pkg/workflow/testdata/TestWasmGolden_CompileFixtures/playwright-cli-mode.golden Golden update to include GH_AW_INFO_ENGINE_ID on setup steps.
pkg/workflow/testdata/TestWasmGolden_CompileFixtures/basic-copilot.golden Golden update to include GH_AW_INFO_ENGINE_ID on setup steps.

Copilot's findings

Tip

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

  • Files reviewed: 6/6 changed files
  • Comments generated: 0

@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot merge main and recompile

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan merged commit befb925 into main May 16, 2026
@pelikhan pelikhan deleted the copilot/grafana-otel-advisor-improve-otel-setup branch May 16, 2026 15:02
Copilot stopped work on behalf of pelikhan due to an error May 16, 2026 15:02
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: emit gh-aw.engine.id and gen_ai.system on the setup span

3 participants