lib/opentelemetry/baggage/propagation/text_map_propagator.rb in opentelemetry-api-1.0.0.rc2 vs lib/opentelemetry/baggage/propagation/text_map_propagator.rb in opentelemetry-api-1.0.0.rc3
- old
+ new
@@ -37,11 +37,12 @@
setter.set(carrier, BAGGAGE_KEY, encoded_baggage) unless encoded_baggage&.empty?
nil
end
# Extract remote baggage from the supplied carrier.
- # If extraction fails, the original context will be returned
+ # If extraction fails or there is no baggage to extract,
+ # then the original context will be returned
#
# @param [Carrier] carrier The carrier to get the header from
# @param [optional Context] context Context to be updated with the baggage
# extracted from the carrier. Defaults to +Context.current+.
# @param [optional Getter] getter If the optional getter is provided, it
@@ -50,10 +51,10 @@
#
# @return [Context] context updated with extracted baggage, or the original context
# if extraction fails
def extract(carrier, context: Context.current, getter: Context::Propagation.text_map_getter)
header = getter.get(carrier, BAGGAGE_KEY)
- return context unless header
+ return context if header.nil? || header.empty?
entries = header.gsub(/\s/, '').split(',')
OpenTelemetry::Baggage.build(context: context) do |builder|
entries.each do |entry|