lib/opentelemetry/context/propagation/rack_env_getter.rb in opentelemetry-api-0.15.0 vs lib/opentelemetry/context/propagation/rack_env_getter.rb in opentelemetry-api-0.16.0
- old
+ new
@@ -14,11 +14,11 @@
# +HTTP_TRACEPARENT+
class RackEnvGetter
# Converts key into a rack-normalized key and reads it from the carrier.
# Useful for extract operations.
def get(carrier, key)
- carrier[to_rack_key(key)]
+ carrier[to_rack_key(key)] || carrier[key]
end
# Reads all keys from a carrier and converts them from the rack-normalized
# form to the original. The resulting keys will be lowercase and
# underscores will be replaced with dashes.
@@ -30,16 +30,18 @@
def to_rack_key(key)
ret = 'HTTP_' + key
ret.tr!('-', '_')
ret.upcase!
+ ret
end
def from_rack_key(key)
start = key.start_with?('HTTP_') ? 5 : 0
ret = key[start..-1]
ret.tr!('_', '-')
ret.downcase!
+ ret
end
end
end
end
end