Search in sources :

Example 1 with LinkData

use of io.opentelemetry.sdk.trace.data.LinkData in project opentelemetry-java by open-telemetry.

the class PostSpansRequestMarshalerTest method testSpanRef.

@Test
void testSpanRef() {
    // prepare
    LinkData link = LinkData.create(createSpanContext(TRACE_ID, SPAN_ID));
    // test
    Model.SpanRef spanRef = parse(Model.SpanRef.getDefaultInstance(), SpanRefMarshaler.create(link));
    // verify
    assertThat(SpanId.fromBytes(spanRef.getSpanId().toByteArray())).isEqualTo(SPAN_ID);
    assertThat(TraceId.fromBytes(spanRef.getTraceId().toByteArray())).isEqualTo(TRACE_ID);
    assertThat(spanRef.getRefType()).isEqualTo(Model.SpanRefType.FOLLOWS_FROM);
}
Also used : LinkData(io.opentelemetry.sdk.trace.data.LinkData) Model(io.opentelemetry.exporter.jaeger.proto.api_v2.Model) Test(org.junit.jupiter.api.Test)

Example 2 with LinkData

use of io.opentelemetry.sdk.trace.data.LinkData in project opentelemetry-java by open-telemetry.

the class AdapterTest method getSpanData.

private static SpanData getSpanData(long startMs, long endMs, SpanKind kind, int totalRecordedEvents, int totalAttributeCount) {
    Attributes attributes = Attributes.of(booleanKey("valueB"), true);
    LinkData link = LinkData.create(createSpanContext(LINK_TRACE_ID, LINK_SPAN_ID), attributes);
    return TestSpanData.builder().setHasEnded(true).setSpanContext(createSpanContext(TRACE_ID, SPAN_ID)).setParentSpanContext(SpanContext.create(TRACE_ID, PARENT_SPAN_ID, TraceFlags.getDefault(), TraceState.getDefault())).setName("GET /api/endpoint").setStartEpochNanos(MILLISECONDS.toNanos(startMs)).setEndEpochNanos(MILLISECONDS.toNanos(endMs)).setAttributes(Attributes.of(booleanKey("valueB"), true)).setTotalAttributeCount(totalAttributeCount).setEvents(Collections.singletonList(getTimedEvent())).setTotalRecordedEvents(totalRecordedEvents).setLinks(Collections.singletonList(link)).setTotalRecordedLinks(1).setKind(kind).setResource(Resource.create(Attributes.empty())).setStatus(StatusData.create(StatusCode.OK, "ok!")).build();
}
Also used : LinkData(io.opentelemetry.sdk.trace.data.LinkData) Attributes(io.opentelemetry.api.common.Attributes)

Example 3 with LinkData

use of io.opentelemetry.sdk.trace.data.LinkData in project opentelemetry-java by open-telemetry.

the class AdapterTest method testSpanRefs.

@Test
void testSpanRefs() {
    // prepare
    LinkData link = LinkData.create(createSpanContext("00000000000000000000000000cba123", "0000000000fed456"));
    // test
    Collection<SpanRef> spanRefs = Adapter.toSpanRefs(Collections.singletonList(link));
    // verify
    // the actual span ref is tested in another test
    assertThat(spanRefs).hasSize(1);
}
Also used : LinkData(io.opentelemetry.sdk.trace.data.LinkData) SpanRef(io.jaegertracing.thriftjava.SpanRef) Test(org.junit.jupiter.api.Test)

Example 4 with LinkData

use of io.opentelemetry.sdk.trace.data.LinkData in project opentelemetry-java by open-telemetry.

the class TestSpanDataTest method link_canSetTotalAttributeCount.

@Test
void link_canSetTotalAttributeCount() {
    LinkData link = LinkData.create(SpanContext.getInvalid());
    assertThat(link.getTotalAttributeCount()).isEqualTo(0);
}
Also used : LinkData(io.opentelemetry.sdk.trace.data.LinkData) Test(org.junit.jupiter.api.Test)

Example 5 with LinkData

use of io.opentelemetry.sdk.trace.data.LinkData in project opentelemetry-java by open-telemetry.

the class TestSpanDataTest method link_defaultTotalAttributeCountIsZero.

@Test
void link_defaultTotalAttributeCountIsZero() {
    LinkData link = LinkData.create(SpanContext.getInvalid());
    assertThat(link.getTotalAttributeCount()).isEqualTo(0);
}
Also used : LinkData(io.opentelemetry.sdk.trace.data.LinkData) Test(org.junit.jupiter.api.Test)

Aggregations

LinkData (io.opentelemetry.sdk.trace.data.LinkData)14 Test (org.junit.jupiter.api.Test)9 Attributes (io.opentelemetry.api.common.Attributes)6 AttributeKey (io.opentelemetry.api.common.AttributeKey)3 SpanContext (io.opentelemetry.api.trace.SpanContext)3 Context (io.opentelemetry.context.Context)3 SpanData (io.opentelemetry.sdk.trace.data.SpanData)3 SpanRef (io.jaegertracing.thriftjava.SpanRef)2 SpanKind (io.opentelemetry.api.trace.SpanKind)2 TraceState (io.opentelemetry.api.trace.TraceState)2 Resource (io.opentelemetry.sdk.resources.Resource)2 SamplingDecision (io.opentelemetry.sdk.trace.samplers.SamplingDecision)2 SamplingResult (io.opentelemetry.sdk.trace.samplers.SamplingResult)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 BaseEncoding (com.google.common.io.BaseEncoding)1 ByteString (com.google.protobuf.ByteString)1 AttributesBuilder (io.opentelemetry.api.common.AttributesBuilder)1 ImmutableSpanContext (io.opentelemetry.api.internal.ImmutableSpanContext)1 io.opentelemetry.api.trace (io.opentelemetry.api.trace)1 Span (io.opentelemetry.api.trace.Span)1