[Repo Assist] fix(tracing): isolate provider tests from ambient GH_AW_OTLP_ENDPOINTS#7478
Merged
lpcox merged 1 commit intoJun 13, 2026
Conversation
Three tests lacked t.Setenv("GH_AW_OTLP_ENDPOINTS", "") guards, causing
failures in CI environments where that variable is set (e.g. the
smoke-otel-tracing workflow that sets it to a JSON-array value):
• TestInitProvider_NoEndpoint_ReturnsNoopProvider — asserts the global
provider is a noop.TracerProvider, but when GH_AW_OTLP_ENDPOINTS is
non-empty resolveExtraEndpoints produces active endpoints, so an SDK
provider is installed instead.
• TestInitProvider_EmptyEndpoint_ReturnsNoopProvider — same path; the
empty cfg.Endpoint is eclipsed by the env-var endpoints.
• TestInitProvider_WithHeaders — the per-subtest httptest.Server is the
intended export target, but GH_AW_OTLP_ENDPOINTS overrides cfg.Endpoint
and routes spans to external URLs. The 3-second timeout fires because
the local server never receives the export request.
Fix: add t.Setenv("GH_AW_OTLP_ENDPOINTS", "") to each affected test so
the env variable is reset to empty for the duration of the test and
automatically restored to its original value by testing.T cleanup.
Related: #7468 (Issues A and B of the reported root cause)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves test isolation in internal/tracing/provider_test.go by ensuring certain provider tests are not affected by an ambient GH_AW_OTLP_ENDPOINTS environment variable set by CI workflows, which can change endpoint selection logic and make tests flaky/fail.
Changes:
- Added
t.Setenv("GH_AW_OTLP_ENDPOINTS", "")toTestInitProvider_NoEndpoint_ReturnsNoopProvider. - Added
t.Setenv("GH_AW_OTLP_ENDPOINTS", "")toTestInitProvider_EmptyEndpoint_ReturnsNoopProvider. - Added
t.Setenv("GH_AW_OTLP_ENDPOINTS", "")toTestInitProvider_WithHeadersto keep spans routed to the per-subtesthttptest.Server.
Show a summary per file
| File | Description |
|---|---|
| internal/tracing/provider_test.go | Clears GH_AW_OTLP_ENDPOINTS in tests that rely on the “no endpoint” and “local httptest endpoint” behaviors, preventing CI env leakage from changing endpoint resolution. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 0
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Closes #7468 (Issues A and B)
Three tests in
internal/tracing/provider_test.golackedt.Setenv("GH_AW_OTLP_ENDPOINTS", "")guards, causing them to fail in CI environments where that variable is set — specifically thesmoke-otel-tracingworkflow which sets it to a JSON-array value.Root Cause
resolveExtraEndpointsreadsGH_AW_OTLP_ENDPOINTSdirectly from the environment. When it is non-empty, the extra endpoints take precedence overcfg.Endpoint, breaking tests that assume no active endpoints:TestInitProvider_NoEndpoint_ReturnsNoopProvidernoop.TracerProvider, but SDK provider is installed when env var is setTestInitProvider_EmptyEndpoint_ReturnsNoopProvidercfg.Endpointeclipsed by env-var endpointsTestInitProvider_WithHeaders(×3 subtests)httptest.Serveris the intended export target, but GH_AW_OTLP_ENDPOINTS routes spans to external garbage URLs; 3s timeout firesFix
Added
t.Setenv("GH_AW_OTLP_ENDPOINTS", "")to each affected test.t.Setenvautomatically restores the original value at test cleanup, so there are no side effects on other tests.The other well-guarded tests (
TestInitProvider_IsEnabled_Noop,TestInitProvider_IsEnabled_SDK,TestInitProvider_FanOut_*) already set this env var correctly.What's Not Fixed Here (Issue C)
Issue C from #7468 —
resolveExtraEndpointsnot parsing the JSON-array format that the smoke workflow produces — is not addressed in this PR. That requires a design decision (support JSON format, or change the workflow to use plain comma-separated URLs per the documented format inAGENTS.md).Test Status
go.opentelemetry.io/otel v1.44.0,github.com/stretchr/testify v1.11.1) are not cached in this environment and the network proxy is blocked, sogo testcannot run. The changes are mechanically correct — they add onlyt.Setenvcalls with the same pattern used in other already-passing tests in the same file.The fix exactly mirrors the pattern already used in:
TestInitProvider_IsEnabled_Noop(line 29)TestInitProvider_IsEnabled_SDK(line 39)TestInitProvider_FanOut_EmptyEnvVar(line 156)Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
proxy.golang.orgSee Network Configuration for more information.
Add this agentic workflows to your repo
To install this agentic workflow, run