Search in sources :

Example 11 with SpanData

use of io.opencensus.trace.export.SpanData in project instrumentation-java by census-instrumentation.

the class SpanBuilderImplTest method startSpanNullParent.

@Test
public void startSpanNullParent() {
    RecordEventsSpanImpl span = (RecordEventsSpanImpl) SpanBuilderImpl.createWithParent(SPAN_NAME, null, spanBuilderOptions).setRecordEvents(true).startSpan();
    assertThat(span.getContext().isValid()).isTrue();
    assertThat(span.getOptions().contains(Options.RECORD_EVENTS)).isTrue();
    assertThat(span.getContext().getTraceOptions().isSampled()).isTrue();
    SpanData spanData = span.toSpanData();
    assertThat(spanData.getParentSpanId()).isNull();
    assertThat(spanData.getHasRemoteParent()).isNull();
    assertThat(spanData.getStartTimestamp()).isEqualTo(testClock.now());
    assertThat(spanData.getName()).isEqualTo(SPAN_NAME);
}
Also used : SpanData(io.opencensus.trace.export.SpanData) Test(org.junit.Test)

Example 12 with SpanData

use of io.opencensus.trace.export.SpanData in project instrumentation-java by census-instrumentation.

the class InProcessSampledSpanStoreImplTest method getLatencySampledSpans.

@Test
public void getLatencySampledSpans() {
    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(25), 0));
    assertThat(samples.size()).isEqualTo(1);
    assertThat(samples.contains(span.toSpanData())).isTrue();
}
Also used : SpanData(io.opencensus.trace.export.SpanData) RecordEventsSpanImpl(io.opencensus.implcore.trace.RecordEventsSpanImpl) Test(org.junit.Test)

Example 13 with SpanData

use of io.opencensus.trace.export.SpanData in project instrumentation-java by census-instrumentation.

the class InProcessSampledSpanStoreImplTest method ignoreNegativeSpanLatency.

@Test
public void ignoreNegativeSpanLatency() {
    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, 0, Long.MAX_VALUE, 0));
    assertThat(samples.size()).isEqualTo(0);
}
Also used : SpanData(io.opencensus.trace.export.SpanData) RecordEventsSpanImpl(io.opencensus.implcore.trace.RecordEventsSpanImpl) Test(org.junit.Test)

Example 14 with SpanData

use of io.opencensus.trace.export.SpanData in project instrumentation-java by census-instrumentation.

the class InProcessSampledSpanStoreImplTest method getErrorSampledSpans_MaxSpansToReturn.

@Test
public void getErrorSampledSpans_MaxSpansToReturn() {
    RecordEventsSpanImpl span1 = createSampledSpan(REGISTERED_SPAN_NAME);
    testClock.advanceTime(Duration.create(0, 1000));
    span1.end(EndSpanOptions.builder().setStatus(Status.CANCELLED).build());
    // 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, 1000));
    span2.end(EndSpanOptions.builder().setStatus(Status.CANCELLED).build());
    Collection<SpanData> samples = sampleStore.getErrorSampledSpans(ErrorFilter.create(REGISTERED_SPAN_NAME, CanonicalCode.CANCELLED, 1));
    assertThat(samples.size()).isEqualTo(1);
    // No order guaranteed so one of the spans should be in the list.
    assertThat(samples).containsAnyOf(span1.toSpanData(), span2.toSpanData());
}
Also used : SpanData(io.opencensus.trace.export.SpanData) RecordEventsSpanImpl(io.opencensus.implcore.trace.RecordEventsSpanImpl) Test(org.junit.Test)

Example 15 with SpanData

use of io.opencensus.trace.export.SpanData in project instrumentation-java by census-instrumentation.

the class InProcessSampledSpanStoreImplTest method getErrorSampledSpans.

@Test
public void getErrorSampledSpans() {
    RecordEventsSpanImpl span = createSampledSpan(REGISTERED_SPAN_NAME);
    testClock.advanceTime(Duration.create(0, 1000));
    span.end(EndSpanOptions.builder().setStatus(Status.CANCELLED).build());
    Collection<SpanData> samples = sampleStore.getErrorSampledSpans(ErrorFilter.create(REGISTERED_SPAN_NAME, CanonicalCode.CANCELLED, 0));
    assertThat(samples.size()).isEqualTo(1);
    assertThat(samples.contains(span.toSpanData())).isTrue();
}
Also used : SpanData(io.opencensus.trace.export.SpanData) RecordEventsSpanImpl(io.opencensus.implcore.trace.RecordEventsSpanImpl) Test(org.junit.Test)

Aggregations

SpanData (io.opencensus.trace.export.SpanData)86 Test (org.junit.Test)74 RecordEventsSpanImpl (io.opencensus.implcore.trace.RecordEventsSpanImpl)18 Link (io.opencensus.trace.Link)17 AttributeValue (io.opencensus.trace.AttributeValue)13 Collectors (java.util.stream.Collectors)13 Scope (org.apache.ignite.spi.tracing.Scope)13 TracingConfigurationCoordinates (org.apache.ignite.spi.tracing.TracingConfigurationCoordinates)13 TracingConfigurationParameters (org.apache.ignite.spi.tracing.TracingConfigurationParameters)13 TracingSpi (org.apache.ignite.spi.tracing.TracingSpi)13 IgniteEx (org.apache.ignite.internal.IgniteEx)12 SAMPLING_RATE_ALWAYS (org.apache.ignite.spi.tracing.TracingConfigurationParameters.SAMPLING_RATE_ALWAYS)12 OpenCensusTracingSpi (org.apache.ignite.spi.tracing.opencensus.OpenCensusTracingSpi)12 SpanId (io.opencensus.trace.SpanId)11 Collections (java.util.Collections)9 SpanType (org.apache.ignite.internal.processors.tracing.SpanType)9 TX (org.apache.ignite.spi.tracing.Scope.TX)9 ArrayList (java.util.ArrayList)8 Arrays (java.util.Arrays)8 Set (java.util.Set)8