Interface Baggage.Builder

  • Enclosing interface:
    Baggage

    public static interface Baggage.Builder
    Builder for the Baggage class.
    • Method Detail

      • setParent

        Baggage.Builder setParent​(io.opentelemetry.context.Context context)
        Sets the parent Baggage to use from the specified Context. If no parent Baggage is provided, the value of Baggage.current() at build() time will be used as parent, unless setNoParent() was called.

        If no parent Baggage is available in the specified Context, the resulting Baggage will become a root instance, as if setNoParent() had been called.

        This must be used to create a Baggage when manual Context propagation is used.

        If called multiple times, only the last specified value will be used.

        Parameters:
        context - the Context.
        Returns:
        this.
        Throws:
        NullPointerException - if context is null.
        See Also:
        setNoParent()
      • put

        Baggage.Builder put​(String key,
                            String value,
                            EntryMetadata entryMetadata)
        Adds the key/value pair and metadata regardless of whether the key is present.
        Parameters:
        key - the String key which will be set.
        value - the String value to set for the given key.
        entryMetadata - the EntryMetadata associated with this Entry.
        Returns:
        this
      • put

        Baggage.Builder put​(String key,
                            String value)
        Adds the key/value pair with empty metadata regardless of whether the key is present.
        Parameters:
        key - the String key which will be set.
        value - the String value to set for the given key.
        Returns:
        this
      • remove

        Baggage.Builder remove​(String key)
        Removes the key if it exists.
        Parameters:
        key - the String key which will be removed.
        Returns:
        this
      • build

        Baggage build()
        Creates a Baggage from this builder.
        Returns:
        a Baggage with the same entries as this builder.