use of io.opencensus.implcore.trace.RecordEventsSpanImpl in project instrumentation-java by census-instrumentation.
the class InProcessRunningSpanStoreImplTest method getSummary_SpansWithSameName.
@Test
public void getSummary_SpansWithSameName() {
final RecordEventsSpanImpl span1 = createSpan(SPAN_NAME_1);
final RecordEventsSpanImpl span2 = createSpan(SPAN_NAME_1);
final RecordEventsSpanImpl span3 = createSpan(SPAN_NAME_1);
assertThat(activeSpansExporter.getSummary().getPerSpanNameSummary().size()).isEqualTo(1);
assertThat(activeSpansExporter.getSummary().getPerSpanNameSummary().get(SPAN_NAME_1).getNumRunningSpans()).isEqualTo(3);
span1.end();
assertThat(activeSpansExporter.getSummary().getPerSpanNameSummary().size()).isEqualTo(1);
assertThat(activeSpansExporter.getSummary().getPerSpanNameSummary().get(SPAN_NAME_1).getNumRunningSpans()).isEqualTo(2);
span2.end();
assertThat(activeSpansExporter.getSummary().getPerSpanNameSummary().size()).isEqualTo(1);
assertThat(activeSpansExporter.getSummary().getPerSpanNameSummary().get(SPAN_NAME_1).getNumRunningSpans()).isEqualTo(1);
span3.end();
assertThat(activeSpansExporter.getSummary().getPerSpanNameSummary().size()).isEqualTo(0);
}
use of io.opencensus.implcore.trace.RecordEventsSpanImpl in project instrumentation-java by census-instrumentation.
the class SpanExporterImplTest method exportDifferentSampledSpans.
@Test
public void exportDifferentSampledSpans() {
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_2);
List<SpanData> exported = serviceHandler.waitForExport(2);
assertThat(exported).containsExactly(span1.toSpanData(), span2.toSpanData());
}
use of io.opencensus.implcore.trace.RecordEventsSpanImpl 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 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());
}
use of io.opencensus.implcore.trace.RecordEventsSpanImpl in project instrumentation-java by census-instrumentation.
the class SpanExporterImplTest method createSampledEndedSpan.
private RecordEventsSpanImpl createSampledEndedSpan(StartEndHandler startEndHandler, String spanName) {
RecordEventsSpanImpl span = RecordEventsSpanImpl.startSpan(sampledSpanContext, spanName, null, null, false, TraceParams.DEFAULT, startEndHandler, null, MillisClock.getInstance());
span.end();
return span;
}
Aggregations