use of io.opentelemetry.proto.common.v1.InstrumentationLibrary in project inspectit-ocelot by inspectIT.
the class OpenTelemetryProtoConverter method toSpanData.
/**
* @return Converts an {@link InstrumentationLibrarySpans} instance to a stream of individual {@link SpanData} instances.
*/
private Stream<SpanData> toSpanData(InstrumentationLibrarySpans librarySpans, Resource resource, Map<String, String> customSpanAttributes) {
InstrumentationLibrary library = librarySpans.getInstrumentationLibrary();
InstrumentationLibraryInfo libraryInfo = InstrumentationLibraryInfo.create(library.getName(), library.getVersion());
return librarySpans.getSpansList().stream().map(protoSpan -> OcelotSpanUtils.createSpanData(protoSpan, resource, libraryInfo, customSpanAttributes)).filter(Objects::nonNull);
}
use of io.opentelemetry.proto.common.v1.InstrumentationLibrary in project wavefront-proxy by wavefrontHQ.
the class OtlpProtobufUtils method fromOtlpRequest.
// TODO: consider transforming a single span and returning it for immedidate reporting in
// wfSender. This could be more efficient, and also more reliable in the event the loops
// below throw an error and we don't report any of the list.
@VisibleForTesting
static List<WavefrontSpanAndLogs> fromOtlpRequest(ExportTraceServiceRequest request, @Nullable ReportableEntityPreprocessor preprocessor, String defaultSource) {
List<WavefrontSpanAndLogs> wfSpansAndLogs = new ArrayList<>();
for (ResourceSpans rSpans : request.getResourceSpansList()) {
Resource resource = rSpans.getResource();
OTLP_DATA_LOGGER.finest(() -> "Inbound OTLP Resource: " + resource);
for (InstrumentationLibrarySpans ilSpans : rSpans.getInstrumentationLibrarySpansList()) {
InstrumentationLibrary iLibrary = ilSpans.getInstrumentationLibrary();
OTLP_DATA_LOGGER.finest(() -> "Inbound OTLP Instrumentation Library: " + iLibrary);
for (io.opentelemetry.proto.trace.v1.Span otlpSpan : ilSpans.getSpansList()) {
OTLP_DATA_LOGGER.finest(() -> "Inbound OTLP Span: " + otlpSpan);
wfSpansAndLogs.add(transformAll(otlpSpan, resource.getAttributesList(), iLibrary, preprocessor, defaultSource));
}
}
}
return wfSpansAndLogs;
}
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 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 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")));
}
Aggregations