Skip to content

Commit

Permalink
fix: patch the issue for frozen string on ruby < 3.0 with string inte…
Browse files Browse the repository at this point in the history
…rpolation (#1493)

* patch the issue for frozen string on ruby < 3.0 with string interpolation

* use + sign for mutable string

---------

Co-authored-by: Matthew Wear <[email protected]>
  • Loading branch information
xuan-cao-swi and mwear authored Aug 2, 2023
1 parent 557baa1 commit f81279a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion api/lib/opentelemetry/context/propagation/rack_env_getter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def keys(carrier)
private

def to_rack_key(key)
ret = 'HTTP_' + key # rubocop:disable Style/StringConcatenation
# Use + for mutable string interpolation in pre-Ruby 3.0.
ret = +"HTTP_#{key}"
ret.tr!('-', '_')
ret.upcase!
ret
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def keys(carrier)
private

def to_rack_key(key)
ret = "HTTP_#{key}"
# Use + for mutable string interpolation in pre-Ruby 3.0.
ret = +"HTTP_#{key}"
ret.tr!('-', '_')
ret.upcase!
ret
Expand Down
3 changes: 2 additions & 1 deletion propagator/jaeger/test/text_map_propagator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ def create_context(trace_id:,
it 'injects to rack keys' do
rack_env_setter = Object.new
def rack_env_setter.set(carrier, key, value)
rack_key = 'HTTP_' + key
# Use + for mutable string interpolation in pre-Ruby 3.0.
rack_key = +"HTTP_#{key}"
rack_key.tr!('-', '_')
rack_key.upcase!
carrier[rack_key] = value
Expand Down

0 comments on commit f81279a

Please sign in to comment.