Module brave

Class PropagationFields<K,​V>

  • Direct Known Subclasses:
    MapPropagationFields, PredefinedPropagationFields

    public abstract class PropagationFields<K,​V>
    extends java.lang.Object
    We need to retain propagation state extracted from headers. However, we don't know the trace identifiers, yet. In order to resolve this ordering concern, we create an object to hold extra state, and defer associating it with a span ID (via ExtraFactory.decorate(TraceContext).

    Implementations of this type should use copy-on-write semantics to prevent changes in a child context from affecting its parent.

    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract void forEach​(PropagationFields.FieldConsumer<K,​V> consumer)
      Invokes the consumer for every non-null field value
      static <K,​V>
      V
      get​(TraceContext context, K key, java.lang.Class<? extends PropagationFields<K,​V>> type)
      Returns the value of the field with the specified key or null if not available
      abstract V get​(K key)
      Returns the value of the field with the specified key or null if not available
      abstract boolean isEmpty()  
      static <K,​V>
      void
      put​(TraceContext context, K key, V value, java.lang.Class<? extends PropagationFields<K,​V>> type)
      Replaces the value of the field with the specified key, ignoring if not a permitted field
      abstract void put​(K key, V value)
      Replaces the value of the field with the specified key, ignoring if not a permitted field
      protected abstract java.util.Map<K,​V> toMap()
      for testing and default toString
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • PropagationFields

        public PropagationFields()
    • Method Detail

      • get

        public abstract V get​(K key)
        Returns the value of the field with the specified key or null if not available
      • put

        public abstract void put​(K key,
                                 V value)
        Replaces the value of the field with the specified key, ignoring if not a permitted field
      • isEmpty

        public abstract boolean isEmpty()
      • toMap

        protected abstract java.util.Map<K,​V> toMap()
        for testing and default toString
      • toString

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

        public static <K,​V> V get​(TraceContext context,
                                        K key,
                                        java.lang.Class<? extends PropagationFields<K,​V>> type)
        Returns the value of the field with the specified key or null if not available
      • put

        public static <K,​V> void put​(TraceContext context,
                                           K key,
                                           V value,
                                           java.lang.Class<? extends PropagationFields<K,​V>> type)
        Replaces the value of the field with the specified key, ignoring if not a permitted field