Search in sources :

Example 1 with InstrumentationLibrary

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);
}
Also used : java.util(java.util) RequestUtils(rocks.inspectit.oce.eum.server.utils.RequestUtils) ImmutableMap(com.google.common.collect.ImmutableMap) Resource(io.opentelemetry.sdk.resources.Resource) Attributes(io.opentelemetry.api.common.Attributes) InstrumentationLibrarySpans(io.opentelemetry.proto.trace.v1.InstrumentationLibrarySpans) Autowired(org.springframework.beans.factory.annotation.Autowired) Supplier(java.util.function.Supplier) InstrumentationLibraryInfo(io.opentelemetry.sdk.common.InstrumentationLibraryInfo) EumServerConfiguration(rocks.inspectit.oce.eum.server.configuration.model.EumServerConfiguration) Slf4j(lombok.extern.slf4j.Slf4j) Component(org.springframework.stereotype.Component) HttpServletRequest(javax.servlet.http.HttpServletRequest) Stream(java.util.stream.Stream) InstrumentationLibrary(io.opentelemetry.proto.common.v1.InstrumentationLibrary) ResourceSpans(io.opentelemetry.proto.trace.v1.ResourceSpans) OcelotSpanUtils(io.opentelemetry.sdk.trace.OcelotSpanUtils) ExportTraceServiceRequest(io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest) SpanData(io.opentelemetry.sdk.trace.data.SpanData) VisibleForTesting(com.google.common.annotations.VisibleForTesting) InstrumentationLibraryInfo(io.opentelemetry.sdk.common.InstrumentationLibraryInfo) InstrumentationLibrary(io.opentelemetry.proto.common.v1.InstrumentationLibrary)

Example 2 with InstrumentationLibrary

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;
}
Also used : InstrumentationLibrarySpans(io.opentelemetry.proto.trace.v1.InstrumentationLibrarySpans) ArrayList(java.util.ArrayList) Resource(io.opentelemetry.proto.resource.v1.Resource) ResourceSpans(io.opentelemetry.proto.trace.v1.ResourceSpans) InstrumentationLibrary(io.opentelemetry.proto.common.v1.InstrumentationLibrary) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 3 with InstrumentationLibrary

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));
}
Also used : Annotation(wavefront.report.Annotation) InstrumentationLibrary(io.opentelemetry.proto.common.v1.InstrumentationLibrary) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with InstrumentationLibrary

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));
}
Also used : InstrumentationLibrary(io.opentelemetry.proto.common.v1.InstrumentationLibrary) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 5 with InstrumentationLibrary

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")));
}
Also used : Span(io.opentelemetry.proto.trace.v1.Span) Annotation(wavefront.report.Annotation) InstrumentationLibrary(io.opentelemetry.proto.common.v1.InstrumentationLibrary) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

InstrumentationLibrary (io.opentelemetry.proto.common.v1.InstrumentationLibrary)10 InstrumentationLibrarySpans (io.opentelemetry.proto.trace.v1.InstrumentationLibrarySpans)5 ResourceSpans (io.opentelemetry.proto.trace.v1.ResourceSpans)5 InstrumentationLibraryInfo (io.opentelemetry.sdk.common.InstrumentationLibraryInfo)5 ArrayList (java.util.ArrayList)5 Attributes (io.opentelemetry.api.common.Attributes)4 ExportTraceServiceRequest (io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest)4 KeyValue (io.opentelemetry.proto.common.v1.KeyValue)4 Metric (io.opentelemetry.proto.metrics.v1.Metric)4 Resource (io.opentelemetry.proto.resource.v1.Resource)4 Span (io.opentelemetry.proto.trace.v1.Span)4 List (java.util.List)4 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)3 AttributeKey.booleanArrayKey (io.opentelemetry.api.common.AttributeKey.booleanArrayKey)3 AttributeKey.doubleArrayKey (io.opentelemetry.api.common.AttributeKey.doubleArrayKey)3 AttributeKey.longArrayKey (io.opentelemetry.api.common.AttributeKey.longArrayKey)3 AttributeKey.stringArrayKey (io.opentelemetry.api.common.AttributeKey.stringArrayKey)3 AttributesBuilder (io.opentelemetry.api.common.AttributesBuilder)3 SpanContext (io.opentelemetry.api.trace.SpanContext)3 SpanKind (io.opentelemetry.api.trace.SpanKind)3