feat(otel): add github.ref and github.sha to span resource attributes#24786
feat(otel): add github.ref and github.sha to span resource attributes#24786
Conversation
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/bd805b69-0bba-432a-8cdd-c765db803deb Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds GitHub branch/ref and commit SHA metadata to the OTLP span resource attributes so traces can be filtered by branch/commit in observability backends.
Changes:
- Read
GITHUB_REF/GITHUB_SHAin both setup and conclusion span emitters. - Conditionally append
github.ref/github.shatoresourceAttributes. - Extend tests to cover presence/absence of the new resource attributes and ensure env teardown includes the new keys.
Show a summary per file
| File | Description |
|---|---|
actions/setup/js/send_otlp_span.cjs |
Adds conditional github.ref and github.sha resource attributes to both setup and conclusion spans. |
actions/setup/js/send_otlp_span.test.cjs |
Adds env teardown keys and new assertions verifying github.ref/github.sha inclusion/omission. |
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: 2
| const actor = process.env.GITHUB_ACTOR || ""; | ||
| const repository = process.env.GITHUB_REPOSITORY || ""; | ||
| const eventName = process.env.GITHUB_EVENT_NAME || ""; | ||
| const ref = process.env.GITHUB_REF || ""; | ||
| const sha = process.env.GITHUB_SHA || ""; |
There was a problem hiding this comment.
The JSDoc for sendJobSetupSpan lists “Environment variables consumed” but doesn’t include the newly read GITHUB_REF/GITHUB_SHA (and also omits some other env vars used in this function). Please update the doc block so it accurately reflects the env vars this span depends on.
| const actor = process.env.GITHUB_ACTOR || ""; | ||
| const repository = process.env.GITHUB_REPOSITORY || ""; | ||
| const eventName = process.env.GITHUB_EVENT_NAME || ""; | ||
| const ref = process.env.GITHUB_REF || ""; | ||
| const sha = process.env.GITHUB_SHA || ""; |
There was a problem hiding this comment.
The sendJobConclusionSpan JSDoc “Environment variables consumed” list should be updated to include GITHUB_REF/GITHUB_SHA now that these values are read and exported as resource attributes.
github.refandgithub.shawere absent from OTel span resource attributes, making it impossible to filter traces by branch or commit SHA in Grafana/Honeycomb/Datadog without manually following run URLs.Changes
send_otlp_span.cjs— readsGITHUB_REFandGITHUB_SHAin bothsendJobSetupSpan()andsendJobConclusionSpan(), conditionally pushinggithub.refandgithub.shatoresourceAttributesfollowing the existinggithub.event_namepattern:send_otlp_span.test.cjs— addsGITHUB_REF/GITHUB_SHAtoenvKeysteardown lists for both span suites; adds present/absent assertion tests for each new attribute in both setup and conclusion spans.