Search in sources :

Example 71 with SpanData

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

the class ZipkinExporterHandlerTest method generateSpan_ServerKind.

@Test
public void generateSpan_ServerKind() {
    SpanData data = SpanData.create(SpanContext.create(TraceId.fromLowerBase16(TRACE_ID), SpanId.fromLowerBase16(SPAN_ID), TraceOptions.builder().setIsSampled(true).build()), // TODO SpanId.fromLowerBase16
    SpanId.fromLowerBase16(PARENT_SPAN_ID), true, /* hasRemoteParent */
    "Recv.helloworld.Greeter.SayHello", /* name */
    Kind.SERVER, /* kind */
    Timestamp.create(1505855794, 194009601), /* startTimestamp */
    Attributes.create(attributes, 0), TimedEvents.create(annotations, 0), TimedEvents.create(messageEvents, 0), Links.create(Collections.<Link>emptyList(), 0), null, /* childSpanCount */
    Status.OK, Timestamp.create(1505855799, 465726528));
    assertThat(ZipkinExporterHandler.generateSpan(data, localEndpoint)).isEqualTo(Span.newBuilder().traceId(TRACE_ID).parentId(PARENT_SPAN_ID).id(SPAN_ID).kind(Span.Kind.SERVER).name(data.getName()).timestamp(1505855794000000L + 194009601L / 1000).duration((1505855799000000L + 465726528L / 1000) - (1505855794000000L + 194009601L / 1000)).localEndpoint(localEndpoint).addAnnotation(1505855799000000L + 433901068L / 1000, "RECEIVED").addAnnotation(1505855799000000L + 459486280L / 1000, "SENT").putTag(ZipkinExporterHandler.STATUS_CODE, "OK").build());
}
Also used : SpanData(io.opencensus.trace.export.SpanData) Link(io.opencensus.trace.Link) Test(org.junit.Test)

Example 72 with SpanData

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

the class ZipkinExporterHandlerTest method generateSpan_WithAttributes.

@Test
public void generateSpan_WithAttributes() {
    Map<String, AttributeValue> attributeMap = new HashMap<String, AttributeValue>();
    attributeMap.put("string", AttributeValue.stringAttributeValue("string value"));
    attributeMap.put("boolean", AttributeValue.booleanAttributeValue(false));
    attributeMap.put("long", AttributeValue.longAttributeValue(9999L));
    SpanData data = SpanData.create(SpanContext.create(TraceId.fromLowerBase16(TRACE_ID), SpanId.fromLowerBase16(SPAN_ID), TraceOptions.builder().setIsSampled(true).build()), // TODO SpanId.fromLowerBase16
    SpanId.fromLowerBase16(PARENT_SPAN_ID), true, /* hasRemoteParent */
    "Sent.helloworld.Greeter.SayHello", /* name */
    Kind.CLIENT, /* kind */
    Timestamp.create(1505855794, 194009601), /* startTimestamp */
    Attributes.create(attributeMap, 0), TimedEvents.create(annotations, 0), TimedEvents.create(messageEvents, 0), Links.create(Collections.<Link>emptyList(), 0), null, /* childSpanCount */
    Status.OK, Timestamp.create(1505855799, 465726528));
    assertThat(ZipkinExporterHandler.generateSpan(data, localEndpoint)).isEqualTo(Span.newBuilder().traceId(TRACE_ID).parentId(PARENT_SPAN_ID).id(SPAN_ID).kind(Span.Kind.CLIENT).name(data.getName()).timestamp(1505855794000000L + 194009601L / 1000).duration((1505855799000000L + 465726528L / 1000) - (1505855794000000L + 194009601L / 1000)).localEndpoint(localEndpoint).addAnnotation(1505855799000000L + 433901068L / 1000, "RECEIVED").addAnnotation(1505855799000000L + 459486280L / 1000, "SENT").putTag(ZipkinExporterHandler.STATUS_CODE, "OK").putTag("string", "string value").putTag("boolean", "false").putTag("long", "9999").build());
}
Also used : AttributeValue(io.opencensus.trace.AttributeValue) SpanData(io.opencensus.trace.export.SpanData) HashMap(java.util.HashMap) Link(io.opencensus.trace.Link) Test(org.junit.Test)

Example 73 with SpanData

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

the class ZipkinExporterHandlerTest method generateSpan_WithErrorStatus.

@Test
public void generateSpan_WithErrorStatus() {
    String errorMessage = "timeout";
    SpanData data = SpanData.create(SpanContext.create(TraceId.fromLowerBase16(TRACE_ID), SpanId.fromLowerBase16(SPAN_ID), TraceOptions.builder().setIsSampled(true).build()), SpanId.fromLowerBase16(PARENT_SPAN_ID), true, /* hasRemoteParent */
    "Recv.helloworld.Greeter.SayHello", /* name */
    Kind.SERVER, /* kind */
    Timestamp.create(1505855794, 194009601), /* startTimestamp */
    Attributes.create(attributes, 0), TimedEvents.create(annotations, 0), TimedEvents.create(messageEvents, 0), Links.create(Collections.<Link>emptyList(), 0), null, /* childSpanCount */
    Status.DEADLINE_EXCEEDED.withDescription(errorMessage), Timestamp.create(1505855799, 465726528));
    assertThat(ZipkinExporterHandler.generateSpan(data, localEndpoint)).isEqualTo(Span.newBuilder().traceId(TRACE_ID).parentId(PARENT_SPAN_ID).id(SPAN_ID).kind(Span.Kind.SERVER).name(data.getName()).timestamp(1505855794000000L + 194009601L / 1000).duration((1505855799000000L + 465726528L / 1000) - (1505855794000000L + 194009601L / 1000)).localEndpoint(localEndpoint).addAnnotation(1505855799000000L + 433901068L / 1000, "RECEIVED").addAnnotation(1505855799000000L + 459486280L / 1000, "SENT").putTag(ZipkinExporterHandler.STATUS_CODE, "DEADLINE_EXCEEDED").putTag(ZipkinExporterHandler.STATUS_DESCRIPTION, errorMessage).putTag(ZipkinExporterHandler.STATUS_ERROR, "DEADLINE_EXCEEDED").build());
}
Also used : SpanData(io.opencensus.trace.export.SpanData) Link(io.opencensus.trace.Link) Test(org.junit.Test)

Example 74 with SpanData

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

the class SpanBuilderImplTest method startSpanNullParentWithRecordEvents.

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

Example 75 with SpanData

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

the class SpanBuilderImplTest method startRemoteSpanInvalidParent.

@Test
public void startRemoteSpanInvalidParent() {
    RecordEventsSpanImpl span = (RecordEventsSpanImpl) SpanBuilderImpl.createWithRemoteParent(SPAN_NAME, SpanContext.INVALID, spanBuilderOptions).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();
}
Also used : SpanData(io.opencensus.trace.export.SpanData) 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