use of io.opencensus.implcore.trace.RecordEventsSpanImpl.StartEndHandler in project instrumentation-java by census-instrumentation.
the class SpanExporterImplTest method serviceHandlerThrowsException.
@Test
public void serviceHandlerThrowsException() {
doThrow(new IllegalArgumentException("No export for you.")).when(mockServiceHandler).export(ArgumentMatchers.<SpanData>anyList());
SpanExporterImpl spanExporter = SpanExporterImpl.create(4, Duration.create(1, 0));
StartEndHandler startEndHandler = new StartEndHandlerImpl(spanExporter, runningSpanStore, sampledSpanStore, new SimpleEventQueue());
spanExporter.registerHandler("test.service", serviceHandler);
spanExporter.registerHandler("mock.service", mockServiceHandler);
RecordEventsSpanImpl span1 = createSampledEndedSpan(startEndHandler, SPAN_NAME_1);
List<SpanData> exported = serviceHandler.waitForExport(1);
assertThat(exported).containsExactly(span1.toSpanData());
// Continue to export after the exception was received.
RecordEventsSpanImpl span2 = createSampledEndedSpan(startEndHandler, SPAN_NAME_1);
exported = serviceHandler.waitForExport(1);
assertThat(exported).containsExactly(span2.toSpanData());
}
use of io.opencensus.implcore.trace.RecordEventsSpanImpl.StartEndHandler in project instrumentation-java by census-instrumentation.
the class SpanExporterImplTest method exportMoreSpansThanTheBufferSize.
@Test
public void exportMoreSpansThanTheBufferSize() {
SpanExporterImpl spanExporter = SpanExporterImpl.create(4, Duration.create(1, 0));
StartEndHandler startEndHandler = new StartEndHandlerImpl(spanExporter, runningSpanStore, sampledSpanStore, new SimpleEventQueue());
spanExporter.registerHandler("test.service", serviceHandler);
RecordEventsSpanImpl span1 = createSampledEndedSpan(startEndHandler, SPAN_NAME_1);
RecordEventsSpanImpl span2 = createSampledEndedSpan(startEndHandler, SPAN_NAME_1);
RecordEventsSpanImpl span3 = createSampledEndedSpan(startEndHandler, SPAN_NAME_1);
RecordEventsSpanImpl span4 = createSampledEndedSpan(startEndHandler, SPAN_NAME_1);
RecordEventsSpanImpl span5 = createSampledEndedSpan(startEndHandler, SPAN_NAME_1);
RecordEventsSpanImpl span6 = createSampledEndedSpan(startEndHandler, SPAN_NAME_1);
List<SpanData> exported = serviceHandler.waitForExport(6);
assertThat(exported).containsExactly(span1.toSpanData(), span2.toSpanData(), span3.toSpanData(), span4.toSpanData(), span5.toSpanData(), span6.toSpanData());
}
Aggregations