-
Notifications
You must be signed in to change notification settings - Fork 280
feat: replace cgi with uri for encode and decode #2028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| require 'cgi' | ||
| require 'uri' | ||
|
|
||
| # OpenTelemetry is an open source observability framework, providing a | ||
| # general-purpose API, SDK, and related tools required for the instrumentation | ||
|
|
@@ -75,7 +75,7 @@ def inject(carrier, context: Context.current, setter: Context::Propagation.text_ | |
| setter.set(carrier, IDENTITY_KEY, trace_span_identity_value) | ||
| OpenTelemetry::Baggage.values(context: context).each do |key, value| | ||
| baggage_key = 'uberctx-' + key | ||
| encoded_value = CGI.escape(value) | ||
| encoded_value = URI.encode_uri_component(value) | ||
| setter.set(carrier, baggage_key, encoded_value) | ||
| end | ||
| carrier | ||
|
|
@@ -110,7 +110,7 @@ def context_with_extracted_baggage(carrier, context, getter) | |
| next unless baggage_key | ||
|
|
||
| raw_value = getter.get(carrier, carrier_key) | ||
| value = CGI.unescape(raw_value) | ||
| value = URI.decode_uri_component(raw_value) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do the same changes need to happen for B3 headers?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems B3 propagator headers should only contain trace ID, span ID, and sampling decision, which have well-defined headers that don't require decoding.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Am I missing something? Then where these baggage headers encoded incorrectly when using the b3 propagators?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not decode before, also I don't see any other language decode these key and value |
||
| b.set_value(baggage_key, value) | ||
| end | ||
| end | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the CGI methods we're calling in the propagators the same in 3.x and 4.x, but the only difference is what needs to be required?
To help me better understand the issue, would something like this also solve the problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, I just saw the conversation on #2016. It sounds like URI is compatible with the spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, other language use their stdlib to decode