Add github.ref_name and github.head_ref to OTLP span resource attributes#27903
Add github.ref_name and github.head_ref to OTLP span resource attributes#27903
github.ref_name and github.head_ref to OTLP span resource attributes#27903Conversation
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/cc34e347-4b4f-425e-8730-7e7f7c3e886e Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/cc34e347-4b4f-425e-8730-7e7f7c3e886e Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/cc34e347-4b4f-425e-8730-7e7f7c3e886e Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
github.ref_name and github.head_ref to OTLP span resource attributes
There was a problem hiding this comment.
Pull request overview
Adds short GitHub ref metadata to OTLP span resource attributes so traces can be filtered/grouped by branch semantics (e.g., main, PR head branch) without parsing github.ref.
Changes:
- Emit
github.ref_namefromGITHUB_REF_NAMEandgithub.head_reffromGITHUB_HEAD_REFin both job setup and job conclusion OTLP payloads. - Extend unit tests to assert presence/absence of the new resource attributes and ensure env var cleanup includes the new keys.
Show a summary per file
| File | Description |
|---|---|
| actions/setup/js/send_otlp_span.cjs | Adds github.ref_name / github.head_ref resource attributes sourced from GITHUB_REF_NAME / GITHUB_HEAD_REF for setup and conclusion spans. |
| actions/setup/js/send_otlp_span.test.cjs | Adds tests for inclusion/omission of the new resource attributes and updates env var cleanup lists. |
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)
actions/setup/js/send_otlp_span.cjs:706
- The sendJobConclusionSpan JSDoc lists the environment variables consumed, but it doesn’t include the newly added GITHUB_REF_NAME / GITHUB_HEAD_REF inputs. Please update the doc comment to reflect these additional env vars.
const refName = process.env.GITHUB_REF_NAME || "";
const headRef = process.env.GITHUB_HEAD_REF || "";
- Files reviewed: 2/2 changed files
- Comments generated: 2
| const refName = process.env.GITHUB_REF_NAME || ""; | ||
| const headRef = process.env.GITHUB_HEAD_REF || ""; |
There was a problem hiding this comment.
The sendJobSetupSpan JSDoc lists the environment variables consumed, but it doesn’t mention the newly added GITHUB_REF_NAME / GITHUB_HEAD_REF inputs. Please update the doc comment so it stays accurate for users debugging or integrating this script.
This issue also appears on line 705 of the same file.
| if (ref) { | ||
| resourceAttributes.push(buildAttr("github.ref", ref)); | ||
| } | ||
| if (refName) { | ||
| resourceAttributes.push(buildAttr("github.ref_name", refName)); | ||
| } | ||
| if (headRef) { | ||
| resourceAttributes.push(buildAttr("github.head_ref", headRef)); | ||
| } |
There was a problem hiding this comment.
Resource attribute construction is now duplicated in both sendJobSetupSpan and sendJobConclusionSpan (including the new ref_name/head_ref additions). Consider extracting this into a shared helper to reduce the risk of the two code paths drifting over time when new GitHub resource attributes are added.
🧪 Test Quality Sentinel ReportTest Quality Score: 75/100
Test Classification Details
Test Inflation NoteThe test file added 66 lines versus 16 production lines (4.1:1). In this case the inflation is not a quality concern — each new attribute ( One minor suggestion: the positive tests (present-when-set) could be made slightly more robust by also asserting that only one entry per key is present (no duplicates), e.g. Language SupportTests analyzed:
Verdict
📖 Understanding Test ClassificationsDesign Tests (High Value) verify what the system does:
Implementation Tests (Low Value) verify how the system does it:
Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators. References: §24806787562
|
There was a problem hiding this comment.
✅ Test Quality Sentinel: 75/100. Test quality is acceptable — 0% of new tests are implementation tests (threshold: 30%). All 4 new tests verify observable OTLP payload content, covering both the positive case (attributes present when env vars set) and the negative case (attributes absent when env vars not set) for both sendJobSetupSpan and sendJobConclusionSpan.
Current OTLP spans only expose
github.ref(full ref path), which makes branch-level filtering/grouping difficult in common observability UIs. This change adds first-class short ref/source-branch attributes so spans can be queried directly by branch semantics.Telemetry resource attributes
actions/setup/js/send_otlp_span.cjsto read and emit:GITHUB_REF_NAME→github.ref_nameGITHUB_HEAD_REF→github.head_refsendJobSetupSpansendJobConclusionSpangithub.refbehavior is preserved.Test coverage for new attributes
actions/setup/js/send_otlp_span.test.cjsfor both setup/conclusion paths to verify:GITHUB_REF_NAMEandGITHUB_HEAD_REFto keep test isolation consistent.