use of io.opencensus.implcore.trace.RecordEventsSpanImpl in project instrumentation-java by census-instrumentation.
the class InProcessSampledSpanStoreImplTest method getLatencySampledSpans_QueryBetweenMultipleBuckets.
@Test
public void getLatencySampledSpans_QueryBetweenMultipleBuckets() {
RecordEventsSpanImpl span1 = createSampledSpan(REGISTERED_SPAN_NAME);
testClock.advanceTime(Duration.create(0, (int) TimeUnit.MICROSECONDS.toNanos(20)));
span1.end();
// Advance time to allow other spans to be sampled.
testClock.advanceTime(Duration.create(5, 0));
RecordEventsSpanImpl span2 = createSampledSpan(REGISTERED_SPAN_NAME);
testClock.advanceTime(Duration.create(0, (int) TimeUnit.MICROSECONDS.toNanos(200)));
span2.end();
Collection<SpanData> samples = sampleStore.getLatencySampledSpans(LatencyFilter.create(REGISTERED_SPAN_NAME, TimeUnit.MICROSECONDS.toNanos(15), TimeUnit.MICROSECONDS.toNanos(250), 0));
assertThat(samples).containsExactly(span1.toSpanData(), span2.toSpanData());
}
use of io.opencensus.implcore.trace.RecordEventsSpanImpl in project instrumentation-java by census-instrumentation.
the class InProcessRunningSpanStoreImplTest method getSummary_SpansWithDifferentNames.
@Test
public void getSummary_SpansWithDifferentNames() {
final RecordEventsSpanImpl span1 = createSpan(SPAN_NAME_1);
final RecordEventsSpanImpl span2 = createSpan(SPAN_NAME_2);
assertThat(activeSpansExporter.getSummary().getPerSpanNameSummary().size()).isEqualTo(2);
assertThat(activeSpansExporter.getSummary().getPerSpanNameSummary().get(SPAN_NAME_1).getNumRunningSpans()).isEqualTo(1);
assertThat(activeSpansExporter.getSummary().getPerSpanNameSummary().get(SPAN_NAME_2).getNumRunningSpans()).isEqualTo(1);
span1.end();
assertThat(activeSpansExporter.getSummary().getPerSpanNameSummary().size()).isEqualTo(1);
assertThat(activeSpansExporter.getSummary().getPerSpanNameSummary().get(SPAN_NAME_1)).isNull();
assertThat(activeSpansExporter.getSummary().getPerSpanNameSummary().get(SPAN_NAME_2).getNumRunningSpans()).isEqualTo(1);
span2.end();
assertThat(activeSpansExporter.getSummary().getPerSpanNameSummary().size()).isEqualTo(0);
}
use of io.opencensus.implcore.trace.RecordEventsSpanImpl in project instrumentation-java by census-instrumentation.
the class InProcessRunningSpanStoreImplTest method getActiveSpans_SpansWithSameName.
@Test
public void getActiveSpans_SpansWithSameName() {
RecordEventsSpanImpl span1 = createSpan(SPAN_NAME_1);
RecordEventsSpanImpl span2 = createSpan(SPAN_NAME_1);
RecordEventsSpanImpl span3 = createSpan(SPAN_NAME_1);
assertThat(activeSpansExporter.getRunningSpans(Filter.create(SPAN_NAME_1, 0))).containsExactly(span1.toSpanData(), span2.toSpanData(), span3.toSpanData());
assertThat(activeSpansExporter.getRunningSpans(Filter.create(SPAN_NAME_1, 2)).size()).isEqualTo(2);
assertThat(activeSpansExporter.getRunningSpans(Filter.create(SPAN_NAME_1, 2))).containsAnyOf(span1.toSpanData(), span2.toSpanData(), span3.toSpanData());
span1.end();
span2.end();
span3.end();
}
use of io.opencensus.implcore.trace.RecordEventsSpanImpl in project instrumentation-java by census-instrumentation.
the class InProcessRunningSpanStoreImplTest method getActiveSpans_SpansWithDifferentNames.
@Test
public void getActiveSpans_SpansWithDifferentNames() {
RecordEventsSpanImpl span1 = createSpan(SPAN_NAME_1);
RecordEventsSpanImpl span2 = createSpan(SPAN_NAME_2);
assertThat(activeSpansExporter.getRunningSpans(Filter.create(SPAN_NAME_1, 0))).containsExactly(span1.toSpanData());
assertThat(activeSpansExporter.getRunningSpans(Filter.create(SPAN_NAME_1, 2))).containsExactly(span1.toSpanData());
assertThat(activeSpansExporter.getRunningSpans(Filter.create(SPAN_NAME_2, 0))).containsExactly(span2.toSpanData());
span1.end();
span2.end();
}
use of io.opencensus.implcore.trace.RecordEventsSpanImpl in project instrumentation-java by census-instrumentation.
the class InProcessRunningSpanStoreImplTest method setMaxNumberOfSpans.
@Test
public void setMaxNumberOfSpans() {
RecordEventsSpanImpl span1 = createSpan(SPAN_NAME_1);
RecordEventsSpanImpl span2 = createSpan(SPAN_NAME_2);
assertThat(activeSpansExporter.getSummary().getPerSpanNameSummary().size()).isEqualTo(2);
// This will reset all the spans.
activeSpansExporter.setMaxNumberOfSpans(10);
assertThat(activeSpansExporter.getSummary().getPerSpanNameSummary().size()).isEqualTo(0);
span1.end();
span2.end();
// Add spans again.
RecordEventsSpanImpl span3 = createSpan(SPAN_NAME_1);
RecordEventsSpanImpl span4 = createSpan(SPAN_NAME_2);
assertThat(activeSpansExporter.getSummary().getPerSpanNameSummary().size()).isEqualTo(2);
span3.end();
span4.end();
assertThat(activeSpansExporter.getSummary().getPerSpanNameSummary().size()).isEqualTo(0);
}
Aggregations