Search in sources :

Example 11 with LinkData

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

the class SpanLinkMarshaler method createRepeated.

static SpanLinkMarshaler[] createRepeated(List<LinkData> links) {
    if (links.isEmpty()) {
        return EMPTY;
    }
    SpanLinkMarshaler[] result = new SpanLinkMarshaler[links.size()];
    int pos = 0;
    for (LinkData link : links) {
        result[pos++] = create(link);
    }
    return result;
}
Also used : LinkData(io.opentelemetry.sdk.trace.data.LinkData)

Example 12 with LinkData

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

the class AdapterTest method testSpanRef.

@Test
void testSpanRef() {
    // prepare
    LinkData link = LinkData.create(createSpanContext(TRACE_ID, SPAN_ID));
    // test
    SpanRef spanRef = Adapter.toSpanRef(link);
    // verify
    assertThat(spanIdFromLong(spanRef.getSpanId())).isEqualTo(SPAN_ID);
    assertThat(traceIdFromLongs(spanRef.getTraceIdHigh(), spanRef.getTraceIdLow())).isEqualTo(TRACE_ID);
    assertThat(spanRef.getRefType()).isEqualTo(SpanRefType.FOLLOWS_FROM);
}
Also used : LinkData(io.opentelemetry.sdk.trace.data.LinkData) SpanRef(io.jaegertracing.thriftjava.SpanRef) Test(org.junit.jupiter.api.Test)

Example 13 with LinkData

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

the class PostSpansRequestMarshalerTest method getSpanData.

private static SpanData getSpanData(long startMs, long endMs, SpanKind kind, int totalRecordedEvents) {
    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(TimeUnit.MILLISECONDS.toNanos(startMs)).setEndEpochNanos(TimeUnit.MILLISECONDS.toNanos(endMs)).setAttributes(Attributes.of(booleanKey("valueB"), true)).setTotalAttributeCount(3).setEvents(Collections.singletonList(getTimedEvent())).setTotalRecordedEvents(totalRecordedEvents).setLinks(Collections.singletonList(link)).setTotalRecordedLinks(1).setKind(kind).setResource(Resource.create(Attributes.empty())).setStatus(StatusData.ok()).build();
}
Also used : LinkData(io.opentelemetry.sdk.trace.data.LinkData) Attributes(io.opentelemetry.api.common.Attributes)

Example 14 with LinkData

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

the class PostSpansRequestMarshalerTest method testSpanRefs.

@Test
void testSpanRefs() {
    // prepare
    LinkData link = LinkData.create(createSpanContext("00000000000000000000000000cba123", "0000000000fed456"));
    // test
    List<SpanRefMarshaler> spanRefs = SpanRefMarshaler.createRepeated(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) 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