Skip to content

Commit

Permalink
Fix native mode and update parent
Browse files Browse the repository at this point in the history
  • Loading branch information
brunobat committed Oct 24, 2023
1 parent 7374302 commit 7f130a9
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 16 deletions.
11 changes: 7 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.quarkiverse</groupId>
<artifactId>quarkiverse-parent</artifactId>
<version>12</version>
<version>15</version>
<relativePath /> <!-- always from repository -->
</parent>

Expand Down Expand Up @@ -34,12 +34,15 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<quarkus.version>3.5.1</quarkus.version>
<quarkus.version>3.5.0</quarkus.version>
<opentelemetry.version>1.30.1</opentelemetry.version>
<opentelemetry-alpha.version>1.30.0-alpha</opentelemetry-alpha.version>

<gcp-opentelemetry.version>0.25.2</gcp-opentelemetry.version>
<gax-grpc.version>2.25.0</gax-grpc.version>
<!-- 2.24.0 and 2.25.x fail with graalvm. Otel is behind as well but it seems to work ok-->
<gcp-opentelemetry.version>0.23.0</gcp-opentelemetry.version>
<!-- 2.24.0 and 2.25.0 fail with graalvm -->
<gax-grpc.version>2.23.0</gax-grpc.version>
<google-auto-value-annotations.version>1.8.2</google-auto-value-annotations.version>

<assertj-core.version>3.24.2</assertj-core.version>
<junit-jupiter.version>1.18.0</junit-jupiter.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.quarkiverse.opentelemetry.exporter.common.runtime;

/**
* The only point in having this class is to allow {@link TracerProviderCustomizer}
* to easily ignore the configured {@link LateBoundSpanProcessor}.
*/
public final class RemovableLateBoundSpanProcessor extends LateBoundSpanProcessor {

public static final RemovableLateBoundSpanProcessor INSTANCE = new RemovableLateBoundSpanProcessor();

private RemovableLateBoundSpanProcessor() {
super(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.quarkus.deployment.annotations.BuildSteps;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.LaunchModeBuildItem;
import io.quarkus.deployment.builditem.nativeimage.NativeImageConfigBuildItem;
import io.quarkus.opentelemetry.deployment.exporter.otlp.ExternalOtelExporterBuildItem;

@BuildSteps(onlyIf = GcpExporterProcessor.GcpExporterEnabled.class)
Expand All @@ -41,6 +42,13 @@ void registerExternalExporter(BuildProducer<ExternalOtelExporterBuildItem> build
buildProducer.produce(new ExternalOtelExporterBuildItem("gcp"));
}

@BuildStep
NativeImageConfigBuildItem nativeImageConfiguration() {
NativeImageConfigBuildItem.Builder builder = NativeImageConfigBuildItem.builder()
.addRuntimeReinitializedClass("com.google.protobuf.UnsafeUtil");
return builder.build();
}

@BuildStep
@Record(RUNTIME_INIT)
SyntheticBeanBuildItem installBatchSpanProcessorForGcp(GcpRecorder recorder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
quarkus.application.name=opentelemetry-exporter-gcp-integration-test
quarkus.application.version=999-SNAPSHOT

quarkus.opentelemetry.tracer.exporter.otlp.enabled=false

simple/mp-rest/url=${test.url}

quarkus.generate-code.grpc.scan-for-imports=all
21 changes: 11 additions & 10 deletions quarkus-opentelemetry-exporter-gcp/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,21 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-grpc-common</artifactId>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-grpc</artifactId>
<version>${gax-grpc.version}</version>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax</artifactId>
<version>${gax-grpc.version}</version>
</dependency>
<dependency>
<groupId>com.google.cloud.opentelemetry</groupId>
<artifactId>exporter-trace</artifactId>
<version>${gcp-opentelemetry.version}</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>com.google.api</groupId>
Expand All @@ -48,16 +59,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-grpc</artifactId>
<version>${gax-grpc.version}</version>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax</artifactId>
<version>${gax-grpc.version}</version>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-exporter-otlp-common</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.quarkiverse.opentelemetry.exporter.gcp.runtime.graal;

import java.io.IOException;
import java.lang.reflect.Field;
import java.security.GeneralSecurityException;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -28,6 +29,8 @@
import io.grpc.MethodDescriptor;
import io.grpc.netty.shaded.io.netty.util.internal.logging.InternalLogLevel;
import io.grpc.netty.shaded.io.netty.util.internal.logging.InternalLogger;
import io.grpc.netty.shaded.io.netty.util.internal.logging.InternalLoggerFactory;
import sun.misc.Unsafe;

/**
* Cut out unsupported and optional features that are only present in grpc-alts.
Expand Down Expand Up @@ -154,9 +157,33 @@ public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(MethodDescriptor<ReqT
}
}

@TargetClass(className = "com.google.protobuf.UnsafeUtil")
final class Target_com_google_protobuf_UnsafeUtil {
@Substitute
static sun.misc.Unsafe getUnsafe() {
try {
Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
theUnsafe.setAccessible(true);
return (Unsafe) theUnsafe.get(null);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

@TargetClass(className = "io.grpc.netty.shaded.io.netty.util.internal.logging.InternalLoggerFactory")
final class Targetio_grpc_netty_shaded_io_netty_util_internal_logging_InternalLoggerFactory {

@Substitute
public static InternalLoggerFactory newDefaultFactory(String name) {
return new InternalLoggerFactory() {
@Override
protected InternalLogger newInstance(String s) {
return getInstance(s);
}
};
}

@Substitute
static InternalLogger getInstance(Class<?> clazz) {
return new InternalLogger() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.jboss.jandex.ParameterizedType;
import org.jboss.jandex.Type;

import io.opentelemetry.exporter.internal.grpc.GrpcSenderProvider;
import io.opentelemetry.sdk.trace.SpanProcessor;
import io.opentelemetry.sdk.trace.export.SpanExporter;
import io.quarkiverse.opentelemetry.exporter.common.runtime.LateBoundSpanProcessor;
Expand All @@ -22,6 +23,8 @@
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.LaunchModeBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem;
import io.quarkus.opentelemetry.deployment.exporter.otlp.ExternalOtelExporterBuildItem;

@BuildSteps(onlyIf = JaegerExporterProcessor.JaegerExporterEnabled.class)
Expand All @@ -35,6 +38,13 @@ public boolean getAsBoolean() {
}
}

@BuildStep
void retainBeans(BuildProducer<ServiceProviderBuildItem> services) {

services.produce(new ServiceProviderBuildItem(GrpcSenderProvider.class.getName(),
"io.opentelemetry.exporter.sender.okhttp.internal.OkHttpGrpcSenderProvider"));
}

@BuildStep
void registerExternalExporter(BuildProducer<ExternalOtelExporterBuildItem> buildProducer) {
buildProducer.produce(new ExternalOtelExporterBuildItem("jaeger"));
Expand Down

0 comments on commit 7f130a9

Please sign in to comment.