lib/opentelemetry/context/propagation/propagator.rb in opentelemetry-api-0.13.0 vs lib/opentelemetry/context/propagation/propagator.rb in opentelemetry-api-0.14.0
- old
+ new
@@ -26,17 +26,17 @@
#
# @param [Object] carrier A carrier to inject context into
# context into
# @param [optional Context] context Context to be injected into carrier. Defaults
# to +Context.current+
- # @param [optional Callable] setter An optional callable that takes a carrier, a key and
- # a value and assigns the key-value pair in the carrier. If omitted the default setter
- # will be used which expects the carrier to respond to [] and []=.
+ # @param [optional Setter] setter If the optional setter is provided, it
+ # will be used to write context into the carrier, otherwise the default
+ # setter will be used.
#
# @return [Object] carrier
- def inject(carrier, context = Context.current, &setter)
- @injector.inject(carrier, context, &setter)
+ def inject(carrier, context: Context.current, setter: Context::Propagation.text_map_setter)
+ @injector.inject(carrier, context, setter)
rescue => e # rubocop:disable Style/RescueStandardError
OpenTelemetry.logger.warn "Error in Propagator#inject #{e.message}"
carrier
end
@@ -44,17 +44,17 @@
# context and logs a warning if an error if extraction fails.
#
# @param [Object] carrier The carrier to extract context from
# @param [optional Context] context Context to be updated with the state
# extracted from the carrier. Defaults to +Context.current+
- # @param [optional Callable] getter An optional callable that takes a carrier and a key and
- # returns the value associated with the key. If omitted the default getter will be used
- # which expects the carrier to respond to [] and []=.
+ # @param [optional Getter] getter If the optional getter is provided, it
+ # will be used to read the header from the carrier, otherwise the default
+ # getter will be used.
#
# @return [Context] a new context updated with state extracted from the
# carrier
- def extract(carrier, context = Context.current, &getter)
- @extractor.extract(carrier, context, &getter)
+ def extract(carrier, context: Context.current, getter: Context::Propagation.text_map_getter)
+ @extractor.extract(carrier, context, getter)
rescue => e # rubocop:disable Style/RescueStandardError
OpenTelemetry.logger.warn "Error in Propagator#extract #{e.message}"
context
end
end