Skip to content

fix(otlp): add standard resource attributes to logSpan tool spans#30215

Merged
pelikhan merged 3 commits intomainfrom
copilot/add-standard-resource-attributes
May 5, 2026
Merged

fix(otlp): add standard resource attributes to logSpan tool spans#30215
pelikhan merged 3 commits intomainfrom
copilot/add-standard-resource-attributes

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 4, 2026

logSpan in otlp.cjs was calling buildOTLPPayload without resourceAttributes or scopeVersion, so every <toolName>.run span carried only service.name as a resource attribute. This made all tool spans invisible to resource-level filters in Grafana/Honeycomb/Datadog while setup and conclusion spans were fully queryable.

Changes

  • send_otlp_span.cjs: extracted a shared buildGitHubActionsResourceAttributes() helper that centralises the standard GitHub Actions resource attribute list. Replaced the previously duplicated blocks in sendJobSetupSpan and sendJobConclusionSpan with calls to this helper, and logSpan now calls it too — ensuring future attribute additions propagate to all span types automatically.

  • otlp.cjs: reads aw_info.json first (like sendJobConclusionSpan does) to resolve staged and scopeVersion, falling back to env vars. This fixes the common runtime shape where GH_AW_INFO_STAGED and GH_AW_INFO_VERSION are absent in later github-script steps. Passes scopeVersion + resourceAttributes to buildOTLPPayload:

    Resource attribute Source
    service.version aw_info.jsonGH_AW_INFO_VERSION
    github.repository GITHUB_REPOSITORY
    github.run_id GITHUB_RUN_ID
    github.event_name GITHUB_EVENT_NAME
    deployment.environment aw_info.jsonGH_AW_INFO_STAGEDstaging/production
    github.actions.run_url GITHUB_REPOSITORY + GITHUB_RUN_ID
    github.ref, github.ref_name, github.head_ref, github.sha, github.workflow_ref standard GITHUB_* vars
  • otlp.test.cjs: mocks buildGitHubActionsResourceAttributes and readJSONIfExists; rewrites resource-attribute tests to check helper call args; adds a new "logSpan — aw_info.json runtime path" test group covering version, agent_version, and staged resolution including priority and fallback scenarios.

After this change, logSpan emits a payload structurally identical to what setup/conclusion spans produce, enabling consistent resource-level queries across the full trace in both env-only and aw_info.json-backed runtime shapes.

The logSpan helper was calling buildOTLPPayload without resourceAttributes
or scopeVersion, so every tool span only had service.name as a resource
attribute. This prevented resource-level filtering by github.repository,
deployment.environment, service.version, etc. in Grafana/Honeycomb/Datadog.

Now logSpan reads the same env vars as job setup/conclusion spans and passes
scopeVersion (from GH_AW_INFO_VERSION) and resourceAttributes (github.repository,
github.run_id, github.event_name, github.ref, github.ref_name, github.head_ref,
github.sha, github.workflow_ref, deployment.environment, github.actions.run_url)
to buildOTLPPayload, making tool spans visible to resource-level queries.

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/86d67f16-59b5-45fe-b11b-9d694dd63c73

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Copilot AI changed the title [WIP] Add standard resource attributes to logSpan tool fix(otlp): add standard resource attributes to logSpan tool spans May 4, 2026
Copilot AI requested a review from mnkiefer May 4, 2026 19:46
@mnkiefer mnkiefer marked this pull request as ready for review May 4, 2026 19:51
Copilot AI review requested due to automatic review settings May 4, 2026 19:51
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 PR aims to make logSpan OTLP spans carry the same resource metadata as setup/conclusion spans so tool spans can participate in resource-level filtering consistently.

Changes:

  • Adds resource-attribute collection and scopeVersion handling to actions/setup/js/otlp.cjs.
  • Expands actions/setup/js/otlp.test.cjs to cover the new resource-attribute wiring.
  • Aligns logSpan payload construction more closely with the existing setup/conclusion OTLP paths.
Show a summary per file
File Description
actions/setup/js/otlp.cjs Adds resource attributes and scope version when building logSpan OTLP payloads.
actions/setup/js/otlp.test.cjs Extends environment setup and adds tests for the new logSpan resource-attribute behavior.

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

Comment thread actions/setup/js/otlp.cjs Outdated
Comment on lines +101 to +103
const workflowRef = process.env.GH_AW_CURRENT_WORKFLOW_REF || process.env.GITHUB_WORKFLOW_REF || "";
const staged = process.env.GH_AW_INFO_STAGED === "true";
const scopeVersion = process.env.GH_AW_INFO_VERSION || "unknown";
Comment thread actions/setup/js/otlp.cjs Outdated
Comment on lines +92 to +94
// Build resource attributes matching what job setup and conclusion spans carry
// so that tool spans are visible to resource-level filtering in Grafana etc.
const repository = process.env.GITHUB_REPOSITORY || "";
Comment on lines +94 to +98
process.env.GITHUB_REPOSITORY = "owner/repo";
process.env.GITHUB_RUN_ID = "99887766";
process.env.GITHUB_EVENT_NAME = "push";
process.env.GH_AW_INFO_VERSION = "v1.2.3";
delete process.env.GH_AW_INFO_STAGED;
@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented May 4, 2026

@copilot review all comments

…n path

- Extract buildGitHubActionsResourceAttributes() into send_otlp_span.cjs and
  use it from sendJobSetupSpan, sendJobConclusionSpan, and logSpan — eliminating
  the third copy of the duplicated resource-attribute builder
- Fix logSpan to read /tmp/gh-aw/aw_info.json for staged/version (like
  sendJobConclusionSpan does), since GH_AW_INFO_STAGED and GH_AW_INFO_VERSION
  are only in env during the setup step and absent in later github-script steps
- Update tests: mock buildGitHubActionsResourceAttributes and readJSONIfExists;
  add test group covering the aw_info.json runtime path for staged and version

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/d60dc9eb-b031-48d7-8fb6-f3defb8c4db5

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 4, 2026

@copilot review all comments

Addressed all three review points in commit 0926c41:

  1. Duplication (otlp.cjs:92-94): extracted buildGitHubActionsResourceAttributes() into send_otlp_span.cjs and replaced the identical blocks in sendJobSetupSpan, sendJobConclusionSpan, and logSpan with a single call.

  2. aw_info.json not read (otlp.cjs:101-103): logSpan now calls readJSONIfExists("/tmp/gh-aw/aw_info.json") before falling back to env vars, matching what sendJobConclusionSpan does — so service.version and staged are correct in the common runtime shape where GH_AW_INFO_VERSION/GH_AW_INFO_STAGED are absent from later github-script steps.

  3. Tests missing aw_info.json path (otlp.test.cjs:94-98): added mockReadJSONIfExists to the mock setup and a new "logSpan — aw_info.json runtime path" describe block that covers version, agent_version, and staged resolution including priority and fallback scenarios.

Copilot AI requested a review from pelikhan May 4, 2026 21:50
@pelikhan pelikhan merged commit 01878c7 into main May 5, 2026
@pelikhan pelikhan deleted the copilot/add-standard-resource-attributes branch May 5, 2026 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants