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