Skip to content

feat(otel): add github.ref and github.sha to span resource attributes#24786

Merged
pelikhan merged 2 commits intomainfrom
copilot/otel-improvement-add-github-ref-sha
Apr 6, 2026
Merged

feat(otel): add github.ref and github.sha to span resource attributes#24786
pelikhan merged 2 commits intomainfrom
copilot/otel-improvement-add-github-ref-sha

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 5, 2026

github.ref and github.sha were 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 — reads GITHUB_REF and GITHUB_SHA in both sendJobSetupSpan() and sendJobConclusionSpan(), conditionally pushing github.ref and github.sha to resourceAttributes following the existing github.event_name pattern:
if (ref) {
  resourceAttributes.push(buildAttr("github.ref", ref));
}
if (sha) {
  resourceAttributes.push(buildAttr("github.sha", sha));
}
  • send_otlp_span.test.cjs — adds GITHUB_REF/GITHUB_SHA to envKeys teardown lists for both span suites; adds present/absent assertion tests for each new attribute in both setup and conclusion spans.

Copilot AI changed the title [WIP] Add github.ref and github.sha to span resource attributes feat(otel): add github.ref and github.sha to span resource attributes Apr 5, 2026
Copilot AI requested a review from pelikhan April 5, 2026 23:20
@pelikhan pelikhan marked this pull request as ready for review April 5, 2026 23:53
Copilot AI review requested due to automatic review settings April 5, 2026 23:53
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

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_SHA in both setup and conclusion span emitters.
  • Conditionally append github.ref / github.sha to resourceAttributes.
  • 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

Comment on lines 389 to +393
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 || "";
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines 576 to +580
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 || "";
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@pelikhan pelikhan merged commit 3f32757 into main Apr 6, 2026
66 of 67 checks passed
@pelikhan pelikhan deleted the copilot/otel-improvement-add-github-ref-sha branch April 6, 2026 00:05
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.

[otel-advisor] OTel improvement: add github.ref and github.sha to span resource attributes

3 participants