Class BaggageSpanProcessor

java.lang.Object
io.opentelemetry.contrib.baggage.processor.BaggageSpanProcessor
All Implemented Interfaces:
io.opentelemetry.sdk.trace.SpanProcessor, Closeable, AutoCloseable

public final class BaggageSpanProcessor extends Object implements io.opentelemetry.sdk.trace.SpanProcessor
This span processor copies attributes stored in Baggage into each newly created Span.
  • Constructor Details

    • BaggageSpanProcessor

      @Deprecated public BaggageSpanProcessor(Predicate<String> baggageKeyPredicate)
      Deprecated.
      Use BaggageSpanProcessor(Collection, Collection) instead. Most usages of this method should be replaceable with glob patterns, but not all thus this method is kept to preserve compatibility.
    • BaggageSpanProcessor

      public BaggageSpanProcessor(@Nullable Collection<String> included, @Nullable Collection<String> excluded)
      Creates a new BaggageSpanProcessor that copies baggage entries with keys that pass the provided include/exclude filtering into the newly created Span, when both arguments are null or empty all baggage are included.
      Parameters:
      included - list of included baggage key patterns to include
      excluded - list of excluded baggage key patterns to exclude
  • Method Details

    • allowAllBaggageKeys

      public static BaggageSpanProcessor allowAllBaggageKeys()
      Creates a new BaggageSpanProcessor that copies all baggage entries into the newly created span.
      Returns:
      baggage span processor including all attributes
    • onStart

      public void onStart(io.opentelemetry.context.Context parentContext, io.opentelemetry.sdk.trace.ReadWriteSpan span)
      Specified by:
      onStart in interface io.opentelemetry.sdk.trace.SpanProcessor
    • isStartRequired

      public boolean isStartRequired()
      Specified by:
      isStartRequired in interface io.opentelemetry.sdk.trace.SpanProcessor
    • onEnd

      public void onEnd(io.opentelemetry.sdk.trace.ReadableSpan span)
      Specified by:
      onEnd in interface io.opentelemetry.sdk.trace.SpanProcessor
    • isEndRequired

      public boolean isEndRequired()
      Specified by:
      isEndRequired in interface io.opentelemetry.sdk.trace.SpanProcessor
    • toString

      public String toString()
      Overrides:
      toString in class Object