Skip to content

Commit fdb6d56

Browse files
committed
comment updates, use URI, fix typing issue
1 parent 8efab4f commit fdb6d56

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

lib/datadog/tracing/distributed/baggage.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,9 @@ def extract(data)
8080

8181
private
8282

83-
# We can't use uri encode because it incorrectly encodes some characters
8483
def encode_item(item, safe_characters)
85-
# Strip whitespace and URL-encode the item
86-
result = CGI.escape(item.strip)
84+
# Use URI encoding as base, then apply W3C Baggage specific transformations
85+
result = URI.encode_www_form_component(item.strip)
8786
# Replace '+' with '%20' for space encoding consistency with W3C spec
8887
result = result.gsub('+', '%20')
8988
# Selectively decode percent-encoded characters that are considered "safe" in W3C Baggage spec

lib/datadog/tracing/distributed/propagation.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def inject!(digest, data)
6363

6464
digest = digest.to_digest if digest.respond_to?(:to_digest)
6565
if digest.trace_id.nil? && digest.baggage.nil?
66-
::Datadog.logger.debug('Cannot inject distributed trace data: digest.trace_id is nil.')
66+
::Datadog.logger.debug('Cannot inject distributed trace data: digest.trace_id and digest.baggage are both nil.')
6767
return nil
6868
end
6969

@@ -142,7 +142,7 @@ def extract(data)
142142
"Error extracting distributed trace data. Cause: #{e} Location: #{Array(e.backtrace).first}"
143143
)
144144
end
145-
# Handle baggage after all other styles if present
145+
# Handle baggage after all other styles
146146
extracted_trace_digest = propagate_baggage(data, extracted_trace_digest) if @baggage_propagator
147147

148148
extracted_trace_digest

0 commit comments

Comments
 (0)