Handle JSON-form GH_AW_OTLP_ENDPOINTS in tracing provider and isolate inherited env in provider tests#7482
Conversation
|
@copilot resolve the merge conflicts in this pull request |
There was a problem hiding this comment.
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_ENDPOINTSparsing 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_ENDPOINTSin 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
| func TestInitProvider_NoEndpoint_ReturnsNoopProvider(t *testing.T) { | ||
| ctx := context.Background() | ||
| t.Setenv("GH_AW_OTLP_ENDPOINTS", "") | ||
|
|
Resolved. The only conflict was in |
|
@copilot resolve the merge conflicts in this pull request |
…acing-fix-init-provider-tests
Resolved. The conflict was again in |
The smoke OTel tracing workflow sets
GH_AW_OTLP_ENDPOINTSas 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
GH_AW_OTLP_ENDPOINTSresolution to accept either:urland optionalheadersExporter construction
OTEL_EXPORTER_OTLP_HEADERS/ config.Regression coverage
GH_AW_OTLP_ENDPOINTSin the affected provider tests so noop and local-collector cases do not depend on ambient workflow env.