Interface SpanProcessor

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
BatchSpanProcessor, SimpleSpanProcessor

@ThreadSafe public interface SpanProcessor extends Closeable
SpanProcessor is the interface SdkTracer uses to allow synchronous hooks for when a Span is started or when a Span is ended.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Closes this SpanProcessor after processing any remaining spans, releasing any resources.
    composite(SpanProcessor... processors)
    Returns a SpanProcessor which simply delegates all processing to the processors in order.
    Returns a SpanProcessor which simply delegates all processing to the processors in order.
    default io.opentelemetry.sdk.common.CompletableResultCode
    Processes all span events that have not yet been processed.
    boolean
    Returns true if this SpanProcessor requires end events.
    boolean
    Returns true if this SpanProcessor requires start events.
    void
    Called when a Span is ended, if the Span.isRecording() returns true.
    void
    onStart(io.opentelemetry.context.Context parentContext, ReadWriteSpan span)
    Called when a Span is started, if the Span.isRecording() returns true.
    default io.opentelemetry.sdk.common.CompletableResultCode
    Processes all span events that have not yet been processed and closes used resources.
  • Method Details

    • composite

      static SpanProcessor composite(SpanProcessor... processors)
      Returns a SpanProcessor which simply delegates all processing to the processors in order.
    • composite

      static SpanProcessor composite(Iterable<SpanProcessor> processors)
      Returns a SpanProcessor which simply delegates all processing to the processors in order.
    • onStart

      void onStart(io.opentelemetry.context.Context parentContext, ReadWriteSpan span)
      Called when a Span is started, if the Span.isRecording() returns true.

      This method is called synchronously on the execution thread, should not throw or block the execution thread.

      Parameters:
      parentContext - the parent Context of the span that just started.
      span - the Span that just started.
    • isStartRequired

      boolean isStartRequired()
      Returns true if this SpanProcessor requires start events.
      Returns:
      true if this SpanProcessor requires start events.
    • onEnd

      void onEnd(ReadableSpan span)
      Called when a Span is ended, if the Span.isRecording() returns true.

      This method is called synchronously on the execution thread, should not throw or block the execution thread.

      Parameters:
      span - the Span that just ended.
    • isEndRequired

      boolean isEndRequired()
      Returns true if this SpanProcessor requires end events.
      Returns:
      true if this SpanProcessor requires end events.
    • shutdown

      default io.opentelemetry.sdk.common.CompletableResultCode shutdown()
      Processes all span events that have not yet been processed and closes used resources.
      Returns:
      a CompletableResultCode which completes when shutdown is finished.
    • forceFlush

      default io.opentelemetry.sdk.common.CompletableResultCode forceFlush()
      Processes all span events that have not yet been processed.
      Returns:
      a CompletableResultCode which completes when currently queued spans are finished processing.
    • close

      default void close()
      Closes this SpanProcessor after processing any remaining spans, releasing any resources.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable