Skip to content

Handle JSON-form GH_AW_OTLP_ENDPOINTS in tracing provider and isolate inherited env in provider tests#7482

Merged
lpcox merged 5 commits into
mainfrom
copilot/smoke-otel-tracing-fix-init-provider-tests
Jun 13, 2026
Merged

Handle JSON-form GH_AW_OTLP_ENDPOINTS in tracing provider and isolate inherited env in provider tests#7482
lpcox merged 5 commits into
mainfrom
copilot/smoke-otel-tracing-fix-init-provider-tests

Conversation

Copilot AI commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

The smoke OTel tracing workflow sets GH_AW_OTLP_ENDPOINTS as a JSON array, but the tracing resolver only handled comma-separated URLs. That caused invalid fan-out endpoints to be constructed, which in turn broke noop-provider expectations and redirected header tests away from their local collectors.

  • Tracing config parsing

    • Teach GH_AW_OTLP_ENDPOINTS resolution to accept either:
      • comma-separated endpoint URLs, or
      • a JSON array of objects with url and optional headers
    • Ignore empty entries and invalid JSON payloads instead of turning them into malformed OTLP endpoints.
  • Exporter construction

    • Preserve existing shared header behavior from OTEL_EXPORTER_OTLP_HEADERS / config.
    • Merge per-endpoint headers from JSON entries into each exporter, with endpoint-specific values taking precedence.
  • Regression coverage

    • Add resolver coverage for JSON arrays, empty arrays, invalid JSON, and endpoint normalization.
    • Add direct coverage for OTLP header merging behavior.
    • Explicitly clear inherited GH_AW_OTLP_ENDPOINTS in the affected provider tests so noop and local-collector cases do not depend on ambient workflow env.
// Existing form
GH_AW_OTLP_ENDPOINTS=http://collector-a:4318,https://collector-b.example.com

// Newly supported workflow form
GH_AW_OTLP_ENDPOINTS=[{"url":"https://collector.example.com/otlp","headers":"Authorization=******"}]

GitHub Advanced Security started work on behalf of lpcox June 13, 2026 14:22 View session
GitHub Advanced Security finished work on behalf of lpcox June 13, 2026 14:23
Copilot AI changed the title [WIP] Fix failing provider initialization tests in smoke-otel-tracing workflow Handle JSON-form GH_AW_OTLP_ENDPOINTS in tracing provider and isolate inherited env in provider tests Jun 13, 2026
Copilot finished work on behalf of lpcox June 13, 2026 14:29
Copilot AI requested a review from lpcox June 13, 2026 14:29
GitHub Advanced Security started work on behalf of lpcox June 13, 2026 14:30 View session
GitHub Advanced Security finished work on behalf of lpcox June 13, 2026 14:31
GitHub Advanced Security started work on behalf of lpcox June 13, 2026 14:34 View session
GitHub Advanced Security finished work on behalf of lpcox June 13, 2026 14:35
@lpcox lpcox marked this pull request as ready for review June 13, 2026 15:49
Copilot AI review requested due to automatic review settings June 13, 2026 15:49
@lpcox

lpcox commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts in this pull request

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the tracing configuration and provider initialization to properly support GH_AW_OTLP_ENDPOINTS when it is provided as a JSON array (as used by the smoke OTel tracing workflow), including per-endpoint header overrides, and adds regression tests around parsing and header merging.

Changes:

  • Extend GH_AW_OTLP_ENDPOINTS parsing to accept either comma-separated URLs or a JSON array of {url, headers} entries, skipping empty entries and treating invalid JSON as “unset”.
  • Update OTLP exporter construction to merge shared headers with endpoint-specific headers (endpoint-specific values take precedence).
  • Add regression tests for JSON endpoint parsing, endpoint normalization, header parsing/merging, and reduce test coupling to inherited GH_AW_OTLP_ENDPOINTS in some provider tests.
Show a summary per file
File Description
internal/tracing/config_resolver.go Adds JSON-array parsing for GH_AW_OTLP_ENDPOINTS, introduces extraEndpointConfig, and normalizes endpoints consistently.
internal/tracing/provider.go Switches provider fan-out selection to extraEndpointConfig and merges shared + per-endpoint OTLP headers for exporter creation.
internal/tracing/resolve_endpoint_test.go Adds coverage for JSON-array parsing, invalid/empty JSON behavior, and normalization behavior.
internal/tracing/provider_test.go Adds a test for JSON per-endpoint headers and clears inherited GH_AW_OTLP_ENDPOINTS in a couple of tests.
internal/tracing/provider_internal_test.go Adds unit tests for mergeOTLPHeaders behavior (override + nil/empty handling).

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 5/5 changed files
  • Comments generated: 1

Comment on lines 171 to 174
func TestInitProvider_NoEndpoint_ReturnsNoopProvider(t *testing.T) {
ctx := context.Background()
t.Setenv("GH_AW_OTLP_ENDPOINTS", "")

Copilot AI commented Jun 13, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Resolved. The only conflict was in internal/tracing/provider_test.go — both sides had the same t.Setenv("GH_AW_OTLP_ENDPOINTS", "") call; origin/main had added explanatory comments alongside it. I kept the commented versions from main in both locations.

GitHub Advanced Security started work on behalf of lpcox June 13, 2026 15:56 View session
Copilot finished work on behalf of lpcox June 13, 2026 15:56
GitHub Advanced Security finished work on behalf of lpcox June 13, 2026 15:57
@lpcox

lpcox commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Jun 13, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Resolved. The conflict was again in internal/tracing/provider.go — our branch had the new mergeOTLPHeaders function while origin/main had added a CachedTracer struct at the same location. I kept both in the merged commit (8a9fdd60).

GitHub Advanced Security started work on behalf of lpcox June 13, 2026 16:03 View session
Copilot finished work on behalf of lpcox June 13, 2026 16:03
GitHub Advanced Security finished work on behalf of lpcox June 13, 2026 16:04
@lpcox lpcox merged commit 82def41 into main Jun 13, 2026
27 checks passed
@lpcox lpcox deleted the copilot/smoke-otel-tracing-fix-init-provider-tests branch June 13, 2026 16:07
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.

3 participants