use of io.opentelemetry.proto.common.v1.InstrumentationLibrary in project wavefront-proxy by wavefrontHQ.
the class OtlpProtobufUtilsTest method transformSpanHandlesInstrumentationLibrary.
@Test
public void transformSpanHandlesInstrumentationLibrary() {
InstrumentationLibrary library = InstrumentationLibrary.newBuilder().setName("grpc").setVersion("1.0").build();
Span otlpSpan = OtlpTestHelpers.otlpSpanGenerator().build();
actualSpan = OtlpProtobufUtils.transformSpan(otlpSpan, emptyAttrs, library, null, "test-source");
assertThat(actualSpan.getAnnotations(), hasItem(new Annotation("otel.scope.name", "grpc")));
assertThat(actualSpan.getAnnotations(), hasItem(new Annotation("otel.scope.version", "1.0")));
}
use of io.opentelemetry.proto.common.v1.InstrumentationLibrary in project wavefront-proxy by wavefrontHQ.
the class OtlpProtobufUtilsTest method annotationsFromInstrumentationLibraryWithNullOrEmptyLibrary.
@Test
public void annotationsFromInstrumentationLibraryWithNullOrEmptyLibrary() {
assertEquals(Collections.emptyList(), OtlpProtobufUtils.annotationsFromInstrumentationLibrary(null));
InstrumentationLibrary emptyLibrary = InstrumentationLibrary.newBuilder().build();
assertEquals(Collections.emptyList(), OtlpProtobufUtils.annotationsFromInstrumentationLibrary(emptyLibrary));
}
use of io.opentelemetry.proto.common.v1.InstrumentationLibrary in project wavefront-proxy by wavefrontHQ.
the class OtlpProtobufUtilsTest method annotationsFromInstrumentationLibraryWithLibraryData.
@Test
public void annotationsFromInstrumentationLibraryWithLibraryData() {
InstrumentationLibrary library = InstrumentationLibrary.newBuilder().setName("net/http").build();
assertEquals(Collections.singletonList(new Annotation("otel.scope.name", "net/http")), OtlpProtobufUtils.annotationsFromInstrumentationLibrary(library));
library = library.toBuilder().setVersion("1.0.0").build();
assertEquals(Arrays.asList(new Annotation("otel.scope.name", "net/http"), new Annotation("otel.scope.version", "1.0.0")), OtlpProtobufUtils.annotationsFromInstrumentationLibrary(library));
}
use of io.opentelemetry.proto.common.v1.InstrumentationLibrary in project java by wavefrontHQ.
the class OtlpProtobufUtils method transformSpan.
@VisibleForTesting
static Span transformSpan(io.opentelemetry.proto.trace.v1.Span otlpSpan, List<KeyValue> resourceAttrs, InstrumentationLibrary iLibrary, ReportableEntityPreprocessor preprocessor, String defaultSource) {
Pair<String, List<KeyValue>> sourceAndResourceAttrs = sourceFromAttributes(resourceAttrs, defaultSource);
String source = sourceAndResourceAttrs._1;
resourceAttrs = sourceAndResourceAttrs._2;
// Order of arguments to Stream.of() matters: when a Resource Attribute and a Span Attribute
// happen to share the same key, we want the Span Attribute to "win" and be preserved.
List<KeyValue> otlpAttributes = Stream.of(resourceAttrs, otlpSpan.getAttributesList()).flatMap(Collection::stream).collect(Collectors.toList());
List<Annotation> wfAnnotations = annotationsFromAttributes(otlpAttributes);
wfAnnotations.add(SPAN_KIND_ANNOTATION_HASH_MAP.get(otlpSpan.getKind()));
wfAnnotations.addAll(annotationsFromStatus(otlpSpan.getStatus()));
wfAnnotations.addAll(annotationsFromInstrumentationLibrary(iLibrary));
wfAnnotations.addAll(annotationsFromDroppedCounts(otlpSpan));
wfAnnotations.addAll(annotationsFromTraceState(otlpSpan.getTraceState()));
wfAnnotations.addAll(annotationsFromParentSpanID(otlpSpan.getParentSpanId()));
String wfSpanId = SpanUtils.toStringId(otlpSpan.getSpanId());
String wfTraceId = SpanUtils.toStringId(otlpSpan.getTraceId());
long startTimeMs = TimeUnit.NANOSECONDS.toMillis(otlpSpan.getStartTimeUnixNano());
long durationMs = otlpSpan.getEndTimeUnixNano() == 0 ? 0 : TimeUnit.NANOSECONDS.toMillis(otlpSpan.getEndTimeUnixNano() - otlpSpan.getStartTimeUnixNano());
wavefront.report.Span toReturn = wavefront.report.Span.newBuilder().setName(otlpSpan.getName()).setSpanId(wfSpanId).setTraceId(wfTraceId).setStartMillis(startTimeMs).setDuration(durationMs).setAnnotations(wfAnnotations).setSource(source).setCustomer("dummy").build();
// apply preprocessor
if (preprocessor != null) {
preprocessor.forSpan().transform(toReturn);
}
// After preprocessor has run `transform()`, set required WF tags that may still be missing
List<Annotation> processedAnnotationList = setRequiredTags(toReturn.getAnnotations());
toReturn.setAnnotations(processedAnnotationList);
return toReturn;
}
use of io.opentelemetry.proto.common.v1.InstrumentationLibrary in project java by wavefrontHQ.
the class OtlpProtobufUtilsTest method annotationsFromInstrumentationLibraryWithNullOrEmptyLibrary.
@Test
public void annotationsFromInstrumentationLibraryWithNullOrEmptyLibrary() {
assertEquals(Collections.emptyList(), OtlpProtobufUtils.annotationsFromInstrumentationLibrary(null));
InstrumentationLibrary emptyLibrary = InstrumentationLibrary.newBuilder().build();
assertEquals(Collections.emptyList(), OtlpProtobufUtils.annotationsFromInstrumentationLibrary(emptyLibrary));
}
Aggregations