use of io.opencensus.implcore.trace.RecordEventsSpanImpl in project instrumentation-java by census-instrumentation.
the class InProcessSampledSpanStoreImplTest method getErrorSampledSpans_NullCode.
@Test
public void getErrorSampledSpans_NullCode() {
RecordEventsSpanImpl span1 = createSampledSpan(REGISTERED_SPAN_NAME);
testClock.advanceTime(Duration.create(0, 1000));
span1.end(EndSpanOptions.builder().setStatus(Status.CANCELLED).build());
RecordEventsSpanImpl span2 = createSampledSpan(REGISTERED_SPAN_NAME);
testClock.advanceTime(Duration.create(0, 1000));
span2.end(EndSpanOptions.builder().setStatus(Status.UNKNOWN).build());
Collection<SpanData> samples = sampleStore.getErrorSampledSpans(ErrorFilter.create(REGISTERED_SPAN_NAME, null, 0));
assertThat(samples.size()).isEqualTo(2);
assertThat(samples).containsExactly(span1.toSpanData(), span2.toSpanData());
}
use of io.opencensus.implcore.trace.RecordEventsSpanImpl in project instrumentation-java by census-instrumentation.
the class InProcessSampledSpanStoreImplTest method getErrorSampledSpans_NullCode_MaxSpansToReturn.
@Test
public void getErrorSampledSpans_NullCode_MaxSpansToReturn() {
RecordEventsSpanImpl span1 = createSampledSpan(REGISTERED_SPAN_NAME);
testClock.advanceTime(Duration.create(0, 1000));
span1.end(EndSpanOptions.builder().setStatus(Status.CANCELLED).build());
RecordEventsSpanImpl span2 = createSampledSpan(REGISTERED_SPAN_NAME);
testClock.advanceTime(Duration.create(0, 1000));
span2.end(EndSpanOptions.builder().setStatus(Status.UNKNOWN).build());
Collection<SpanData> samples = sampleStore.getErrorSampledSpans(ErrorFilter.create(REGISTERED_SPAN_NAME, null, 1));
assertThat(samples.size()).isEqualTo(1);
assertThat(samples).containsAnyOf(span1.toSpanData(), span2.toSpanData());
}
use of io.opencensus.implcore.trace.RecordEventsSpanImpl in project instrumentation-java by census-instrumentation.
the class InProcessSampledSpanStoreImplTest method getLatencySampledSpans_MaxSpansToReturn.
@Test
public void getLatencySampledSpans_MaxSpansToReturn() {
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), 1));
assertThat(samples.size()).isEqualTo(1);
assertThat(samples.contains(span1.toSpanData())).isTrue();
}
use of io.opencensus.implcore.trace.RecordEventsSpanImpl in project instrumentation-java by census-instrumentation.
the class InProcessSampledSpanStoreImplTest method getLatencySampledSpans_ExclusiveUpperBound.
@Test
public void getLatencySampledSpans_ExclusiveUpperBound() {
RecordEventsSpanImpl span = createSampledSpan(REGISTERED_SPAN_NAME);
testClock.advanceTime(Duration.create(0, (int) TimeUnit.MICROSECONDS.toNanos(20)));
span.end();
Collection<SpanData> samples = sampleStore.getLatencySampledSpans(LatencyFilter.create(REGISTERED_SPAN_NAME, TimeUnit.MICROSECONDS.toNanos(15), TimeUnit.MICROSECONDS.toNanos(20), 0));
assertThat(samples.size()).isEqualTo(0);
}
use of io.opencensus.implcore.trace.RecordEventsSpanImpl in project instrumentation-java by census-instrumentation.
the class InProcessSampledSpanStoreImplTest method getLatencySampledSpans_InclusiveLowerBound.
@Test
public void getLatencySampledSpans_InclusiveLowerBound() {
RecordEventsSpanImpl span = createSampledSpan(REGISTERED_SPAN_NAME);
testClock.advanceTime(Duration.create(0, (int) TimeUnit.MICROSECONDS.toNanos(20)));
span.end();
Collection<SpanData> samples = sampleStore.getLatencySampledSpans(LatencyFilter.create(REGISTERED_SPAN_NAME, TimeUnit.MICROSECONDS.toNanos(20), TimeUnit.MICROSECONDS.toNanos(25), 0));
assertThat(samples.size()).isEqualTo(1);
assertThat(samples.contains(span.toSpanData())).isTrue();
}
Aggregations