Interface Baggage

  • All Superinterfaces:
    io.opentelemetry.context.ImplicitContextKeyed

    @Immutable
    public interface Baggage
    extends io.opentelemetry.context.ImplicitContextKeyed
    A map from String to String and EntryMetadata that can be used to label anything that is associated with a specific operation.

    For example, Baggages can be used to label stats, log messages, or debugging information.

    • Method Detail

      • empty

        static Baggage empty()
        Baggage with no entries.
      • current

        static Baggage current()
        Returns Baggage from the current Context, falling back to empty Baggage if none is in the current Context.
      • fromContext

        static Baggage fromContext​(io.opentelemetry.context.Context context)
        Returns the Baggage from the specified Context, falling back to a empty Baggage if there is no baggage in the context.
      • fromContextOrNull

        @Nullable
        static Baggage fromContextOrNull​(io.opentelemetry.context.Context context)
        Returns the Baggage from the specified Context, or null if there is no baggage in the context.
      • storeInContext

        default io.opentelemetry.context.Context storeInContext​(io.opentelemetry.context.Context context)
        Specified by:
        storeInContext in interface io.opentelemetry.context.ImplicitContextKeyed
      • size

        int size()
        Returns the number of entries in this Baggage.
      • isEmpty

        default boolean isEmpty()
        Returns whether this Baggage is empty, containing no entries.
      • getEntryValue

        @Nullable
        String getEntryValue​(String entryKey)
        Returns the String value associated with the given key, without metadata.
        Parameters:
        entryKey - entry key to return the value for.
        Returns:
        the value associated with the given key, or null if no Entry with the given entryKey is in this Baggage.
      • toBuilder

        BaggageBuilder toBuilder()
        Create a Builder pre-initialized with the contents of this Baggage. The returned Builder will be set to not use an implicit parent, so any parent assignment must be done manually.