Interface SpanProcessor

All Superinterfaces:
AutoCloseable, Closeable
All Known Subinterfaces:
ExtendedSpanProcessor
All Known Implementing Classes:
BatchSpanProcessor, MultiSpanProcessor, NoopSpanProcessor, 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 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(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 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 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