Interface Propagator.Getter<C>

Type Parameters:
C - carrier of propagation fields, such as an http request.
Enclosing interface:
Propagator

public static interface Propagator.Getter<C>
Interface that allows a Propagator to read propagated fields from a carrier.

Getter is stateless and allows to be saved as a constant to avoid runtime allocations.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Propagator.Getter
    A noop implementation.
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable String
    get(C carrier, String key)
    Returns the first value of the given propagation key or returns null.
    default Iterable<String>
    getAll(C carrier, String key)
    Get all values of the given propagation key, if any exist.
  • Field Details

  • Method Details

    • get

      @Nullable String get(C carrier, String key)
      Returns the first value of the given propagation key or returns null.
      Parameters:
      carrier - carrier of propagation fields, such as an http request.
      key - the key of the field.
      Returns:
      the first value of the given propagation key or returns null.
    • getAll

      default Iterable<String> getAll(C carrier, String key)
      Get all values of the given propagation key, if any exist. This should only be used when it is expected that the key may be repeated. get(Object, String) should be preferred in other cases for performance.
      Parameters:
      carrier - carrier of propagation fields, such as an http request.
      key - the key of the field.
      Returns:
      all values of the given propagation key or returns an empty Iterable if no values are found.
      Since:
      1.6.0
      Implementation Note:
      For backward-compatibility, a default implementation is provided that returns a list with the value of get(Object, String) or an empty list if no values are found. Implementors of this interface should override this method to provide an implementation that returns all present values of the given propagation key.