Interface BaggageInScope

All Superinterfaces:
AutoCloseable, Closeable

public interface BaggageInScope extends Closeable
Inspired by OpenZipkin Brave's BaggageField. Since some tracer implementations require a scope to be wrapped around baggage, baggage must be closed so that the scope does not leak. Some tracer implementations make baggage immutable (e.g. OpenTelemetry), so when the value gets updated they might create new scope (others will return the same one - e.g. OpenZipkin Brave). Represents a single baggage entry.
Since:
3.0.0
Author:
Marcin Grzejszczak
  • Method Details

    • name

      String name()
      Returns:
      name of the baggage entry
    • get

      @Nullable String get()
      Returns:
      value of the baggage entry or null if not set.
    • get

      @Nullable String get(TraceContext traceContext)
      Retrieves baggage from the given TraceContext.
      Parameters:
      traceContext - context containing baggage
      Returns:
      value of the baggage entry or null if not set.
    • set

      BaggageInScope set(String value)
      Sets the baggage value.
      Parameters:
      value - to set
      Returns:
      new scope
    • set

      BaggageInScope set(TraceContext traceContext, String value)
      Sets the baggage value for the given TraceContext.
      Parameters:
      traceContext - context containing baggage
      value - to set
      Returns:
      new scope
    • makeCurrent

      BaggageInScope makeCurrent()
      Sets the current baggage in scope.
      Returns:
      this in scope
    • close

      void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable