Class TestHandler

java.lang.Object
io.opencensus.trace.export.SpanExporter.Handler
io.opencensus.testing.export.TestHandler

public final class TestHandler extends SpanExporter.Handler
A SpanExporter.Handler for testing only.
Since:
0.9
  • Field Details

    • monitor

      private final Object monitor
    • spanDataList

      private final List<SpanData> spanDataList
  • Constructor Details

    • TestHandler

      public TestHandler()
  • Method Details

    • export

      public void export(Collection<SpanData> spanDataList)
      Description copied from class: SpanExporter.Handler
      Exports a list of sampled (see TraceOptions.isSampled()) Spans using the immutable representation SpanData.

      This may be called from a different thread than the one that called Span.end().

      Implementation SHOULD not block the calling thread. It should execute the export on a different thread if possible.

      Specified by:
      export in class SpanExporter.Handler
      Parameters:
      spanDataList - a list of SpanData objects to be exported.
    • waitForExport

      @Nullable public List<SpanData> waitForExport(int numberOfSpans)
      Waits until we received numberOfSpans spans to export. Returns the list of exported SpanData objects, otherwise null if the current thread is interrupted.
      Parameters:
      numberOfSpans - the number of minimum spans to be collected.
      Returns:
      the list of exported SpanData objects, otherwise null if the current thread is interrupted.
      Since:
      0.9