Percent-encode OTEL_RESOURCE_ATTRIBUTES values for strict OpenTelemetry consumers#39596
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates gh-aw’s OpenTelemetry resource attribute handling to emit RFC 3986 percent-encoded OTEL_RESOURCE_ATTRIBUTES values (instead of legacy backslash escaping) and teaches the in-repo JavaScript OTLP sender to percent-decode keys/values while remaining compatible with the legacy escape format.
Changes:
- Go compiler: percent-encode all non-unreserved bytes in
OTEL_RESOURCE_ATTRIBUTESdynamic values (workflow name, engine ID). - JS OTLP consumer: decode percent-encoded components while preserving legacy backslash-escape parsing behavior.
- Tests: update/extend coverage to assert percent-encoded emission and percent-decoding.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/observability_otlp.go | Switches OTEL resource attribute value encoding to RFC 3986 percent-encoding. |
| pkg/workflow/observability_otlp_test.go | Updates assertions to expect percent-encoded OTEL_RESOURCE_ATTRIBUTES output. |
| actions/setup/js/send_otlp_span.cjs | Adds percent-decoding during OTEL_RESOURCE_ATTRIBUTES parsing while keeping legacy escape support. |
| actions/setup/js/send_otlp_span.test.cjs | Adds a percent-encoded parsing test and updates span resource attribute expectations accordingly. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/4 changed files
- Comments generated: 1
| @@ -768,7 +764,21 @@ func otelServiceName(workflowData *WorkflowData) string { | |||
| } | |||
|
|
|||
| func escapeOTELResourceAttributeValue(value string) string { | |||
|
|
||
| func escapeOTELResourceAttributeValue(value string) string { | ||
| return otelResourceValueEscaper.Replace(value) | ||
| const hexDigits = "0123456789ABCDEF" |
There was a problem hiding this comment.
@copilot use native Go function from go packages to uri encode
There was a problem hiding this comment.
Addressed in 8ee0539. This now uses Go's native URL-encoding helper (url.QueryEscape) with + normalized to %20, which preserves the RFC 3986 percent-encoded output required for OTEL_RESOURCE_ATTRIBUTES.
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot run pr-finisher skill |
Ran the finisher pass. No further code changes were needed; local |
OTEL_RESOURCE_ATTRIBUTESwas emitted with raw spaces and legacy backslash escaping, which is non-compliant with the OpenTelemetry env-var format. Strict SDKs can reject the entire resource when any attribute value is malformed, dropping allgh-aw.*attributes on downstream spans.Compiler: emit spec-compliant resource attributes
OTEL_RESOURCE_ATTRIBUTESvalues.unreservedbytes, covering spaces, commas, equals signs, backslashes, apostrophes, and similar characters in workflow names / engine IDs.JS OTLP consumer: accept the new format
Coverage updates
OTEL_RESOURCE_ATTRIBUTESalongside legacy escaped input.Example: