lib/opentelemetry/baggage/propagation/text_map_propagator.rb in opentelemetry-api-1.0.0.rc1 vs lib/opentelemetry/baggage/propagation/text_map_propagator.rb in opentelemetry-api-1.0.0.rc2
- old
+ new
@@ -27,11 +27,11 @@
# @param [Context] context The context to read baggage from
# @param [optional Setter] setter If the optional setter is provided, it
# will be used to write context into the carrier, otherwise the default
# text map setter will be used.
def inject(carrier, context: Context.current, setter: Context::Propagation.text_map_setter)
- baggage = OpenTelemetry.baggage.raw_entries(context: context)
+ baggage = OpenTelemetry::Baggage.raw_entries(context: context)
return if baggage.nil? || baggage.empty?
encoded_baggage = encode(baggage)
setter.set(carrier, BAGGAGE_KEY, encoded_baggage) unless encoded_baggage&.empty?
@@ -50,13 +50,14 @@
#
# @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
entries = header.gsub(/\s/, '').split(',')
- OpenTelemetry.baggage.build(context: context) do |builder|
+ OpenTelemetry::Baggage.build(context: context) do |builder|
entries.each do |entry|
# Note metadata is currently unused in OpenTelemetry, but is part
# the W3C spec where it's referred to as properties. We preserve
# the properties (as-is) so that they can be propagated elsewhere.
kv, meta = entry.split(';', 2)