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;
}
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);
}
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();
}
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);
}
Aggregations