fix(otlp): add standard resource attributes to logSpan tool spans#30215
fix(otlp): add standard resource attributes to logSpan tool spans#30215
Conversation
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>
There was a problem hiding this comment.
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
scopeVersionhandling toactions/setup/js/otlp.cjs. - Expands
actions/setup/js/otlp.test.cjsto cover the new resource-attribute wiring. - Aligns
logSpanpayload 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
| 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"; |
| // 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 || ""; |
| 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; |
|
@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>
Addressed all three review points in commit
|
logSpaninotlp.cjswas callingbuildOTLPPayloadwithoutresourceAttributesorscopeVersion, so every<toolName>.runspan carried onlyservice.nameas 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 sharedbuildGitHubActionsResourceAttributes()helper that centralises the standard GitHub Actions resource attribute list. Replaced the previously duplicated blocks insendJobSetupSpanandsendJobConclusionSpanwith calls to this helper, andlogSpannow calls it too — ensuring future attribute additions propagate to all span types automatically.otlp.cjs: readsaw_info.jsonfirst (likesendJobConclusionSpandoes) to resolvestagedandscopeVersion, falling back to env vars. This fixes the common runtime shape whereGH_AW_INFO_STAGEDandGH_AW_INFO_VERSIONare absent in later github-script steps. PassesscopeVersion+resourceAttributestobuildOTLPPayload:service.versionaw_info.json→GH_AW_INFO_VERSIONgithub.repositoryGITHUB_REPOSITORYgithub.run_idGITHUB_RUN_IDgithub.event_nameGITHUB_EVENT_NAMEdeployment.environmentaw_info.json→GH_AW_INFO_STAGED→staging/productiongithub.actions.run_urlGITHUB_REPOSITORY+GITHUB_RUN_IDgithub.ref,github.ref_name,github.head_ref,github.sha,github.workflow_refGITHUB_*varsotlp.test.cjs: mocksbuildGitHubActionsResourceAttributesandreadJSONIfExists; rewrites resource-attribute tests to check helper call args; adds a new"logSpan — aw_info.json runtime path"test group coveringversion,agent_version, andstagedresolution including priority and fallback scenarios.After this change,
logSpanemits a payload structurally identical to what setup/conclusion spans produce, enabling consistent resource-level queries across the full trace in both env-only andaw_info.json-backed runtime shapes.