File tree 2 files changed +4
-5
lines changed
lib/datadog/tracing/distributed
2 files changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -80,10 +80,9 @@ def extract(data)
80
80
81
81
private
82
82
83
- # We can't use uri encode because it incorrectly encodes some characters
84
83
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 )
87
86
# Replace '+' with '%20' for space encoding consistency with W3C spec
88
87
result = result . gsub ( '+' , '%20' )
89
88
# Selectively decode percent-encoded characters that are considered "safe" in W3C Baggage spec
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ def inject!(digest, data)
63
63
64
64
digest = digest . to_digest if digest . respond_to? ( :to_digest )
65
65
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.' )
67
67
return nil
68
68
end
69
69
@@ -142,7 +142,7 @@ def extract(data)
142
142
"Error extracting distributed trace data. Cause: #{ e } Location: #{ Array ( e . backtrace ) . first } "
143
143
)
144
144
end
145
- # Handle baggage after all other styles if present
145
+ # Handle baggage after all other styles
146
146
extracted_trace_digest = propagate_baggage ( data , extracted_trace_digest ) if @baggage_propagator
147
147
148
148
extracted_trace_digest
You can’t perform that action at this time.
0 commit comments