Class MultiTextMapPropagator

    • Field Detail

      • allFields

        private final java.util.Collection<java.lang.String> allFields
    • Constructor Detail

      • MultiTextMapPropagator

        MultiTextMapPropagator​(TextMapPropagator... textMapPropagators)
      • MultiTextMapPropagator

        MultiTextMapPropagator​(java.util.List<TextMapPropagator> textMapPropagators)
    • Method Detail

      • fields

        public java.util.Collection<java.lang.String> fields()
        Description copied from interface: TextMapPropagator
        The propagation fields defined. If your carrier is reused, you should delete the fields here before calling TextMapPropagator.inject(Context, Object, TextMapSetter) )}.

        For example, if the carrier is a single-use or immutable request object, you don't need to clear fields as they couldn't have been set before. If it is a mutable, retryable object, successive calls should clear these fields first.

        Some use cases for this are:

        • Allow pre-allocation of fields, especially in systems like gRPC Metadata
        • Allow a single-pass over an iterator
        Specified by:
        fields in interface TextMapPropagator
        Returns:
        the fields that will be used by this formatter.
      • getAllFields

        private static java.util.List<java.lang.String> getAllFields​(TextMapPropagator[] textPropagators)
      • inject

        public <C> void inject​(Context context,
                               @Nullable
                               C carrier,
                               TextMapSetter<C> setter)
        Description copied from interface: TextMapPropagator
        Injects data for downstream consumers, for example as HTTP headers. The carrier may be null to facilitate calling this method with a lambda for the TextMapSetter, in which case that null will be passed to the TextMapSetter implementation.
        Specified by:
        inject in interface TextMapPropagator
        Type Parameters:
        C - carrier of propagation fields, such as an http request
        Parameters:
        context - the Context containing the value to be injected.
        carrier - holds propagation fields. For example, an outgoing message or http request.
        setter - invoked for each propagation key to add or remove.
      • extract

        public <C> Context extract​(Context context,
                                   @Nullable
                                   C carrier,
                                   TextMapGetter<C> getter)
        Description copied from interface: TextMapPropagator
        Extracts data from upstream. For example, from incoming http headers. The returned Context should contain the extracted data, if any, merged with the data from the passed-in Context.

        If the incoming information could not be parsed, implementations MUST return the original Context, unaltered.

        Specified by:
        extract in interface TextMapPropagator
        Type Parameters:
        C - the type of carrier of the propagation fields, such as an http request.
        Parameters:
        context - the Context used to store the extracted value.
        carrier - holds propagation fields. For example, an outgoing message or http request.
        getter - invoked for each propagation key to get data from the carrier.
        Returns:
        the Context containing the extracted data.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object