quarkus: Using OpenCensus with Quarkus produces NullPointerException in native image
Bug Description Using OpenCensus 0.26 with Quarkus 1.4.1.Final in native image produces a NullPointerException when using the io.opencensus.trace.Tracer.
Expected behavior The Tracing should work.
Actual behavior Using OpenCensus 0.26 with Quarkus 1.4.1.Final in native image produces a NullPointerException when using the io.opencensus.trace.Tracer.
2020-05-04 18:40:27,175 ERROR [com.deu.gcp.exc.DefaultExceptionHandler] (executor-thread-1) DefaultExceptionHandler processing exception: java.lang.NullPointerException at io.opencensus.impl.internal.DisruptorEventQueue$1.enqueue(DisruptorEventQueue.java:137) at io.opencensus.impl.internal.DisruptorEventQueue.enqueue(DisruptorEventQueue.java:162) at io.opencensus.implcore.trace.StartEndHandlerImpl.onEnd(StartEndHandlerImpl.java:72) at io.opencensus.implcore.trace.RecordEventsSpanImpl.end(RecordEventsSpanImpl.java:384) at io.opencensus.trace.Span.end(Span.java:244) at io.opencensus.trace.CurrentSpanUtils$ScopeInSpan.close(CurrentSpanUtils.java:100)
During the native image build, a warning is printed
Warning: RecomputeFieldValue.ArrayIndexScale automatic substitution failed. The automatic substitution registration was attempted because a call to jdk.internal.misc.Unsafe.arrayIndexScale(Class) was detected in the static initializer of com.lmax.disruptor.RingBufferFields. Detailed failure reason(s): Could not determine the field where the value produced by the call to jdk.internal.misc.Unsafe.arrayIndexScale(Class) for the array index scale computation is stored. The call is not directly followed by a field store or by a sign extend node followed directly by a field store.
To Reproduce Steps to reproduce the behavior:
- Clone the extension (git clone https://github.com/thankthemaker/quarkus-opencensus-extension)
- Build the extension (mvn clean install)
- Clone the example app (git clone https://github.com/thankthemaker/opencensus-example)
- Build the native image (mvn clean package -Pnative)
- watch out for the warnings during native image build
- run the native image (./target/opencensus-example-1.0.0-SNAPSHOT-runner)
- make a request to the hello endpoint (e.g. curl localhost:8080/hello)
- watch out for the NullPointerException, produced at io.opencensus.impl.internal.DisruptorEventQueue$1.enqueue(DisruptorEventQueue.java:137) R
Configuration
# Add your application.properties here, if applicable.
Screenshots (If applicable, add screenshots to help explain your problem.)
Environment (please complete the following information): Darwin Kernel Version 19.3.0: Thu Jan 9 20:58:23 PST 2020; root:xnu-6153.81.5~1/RELEASE_X86_64 x86_64
openjdk version “11.0.6” 2020-01-14 OpenJDK Runtime Environment GraalVM CE 20.0.0 (build 11.0.6+9-jvmci-20.0-b02) OpenJDK 64-Bit Server VM GraalVM CE 20.0.0 (build 11.0.6+9-jvmci-20.0-b02, mixed mode, sharing)
Quarkus version 1.4.1.Final:
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: /Users/dgey/apache-maven-3.6.3 Java version: 11.0.6, vendor: Oracle Corporation, runtime: /Users/dgey/graalvm-ce-java11-20.0.0/Contents/Home Default locale: de_DE, platform encoding: UTF-8 OS name: “mac os x”, version: “10.15.3”, arch: “x86_64”, family: “mac”
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 27 (14 by maintainers)
Slight tangent, but we’re beginning to work on OpenTelemetry for Quarkus and SmallRye, which is the replacement for OpenCensus.
I’ve created https://github.com/quarkusio/quarkus/issues/10499 to track the work on the Quarkus side, but there are also things happening in SmallRye for it too
I don’t know of any examples of doing this exact thing, but there are plenty of examples in the Quarkus and GraalVM code bases of using
@Substitute
and@InjectAccessors
which would hopefully be sufficient to piece it together. Check out the GraalVM documentation for those annotations as well.Our netty extension probably does the most complicated substitutions, so it should be a great place to get inspiration from.
Cool, thanks for the hint. I will have a look at that, never dealed with substitutions before.
It looks like
RingBuffer
is doing some stuff withsun.misc.Unsafe
: https://github.com/LMAX-Exchange/disruptor/blob/master/src/main/java/com/lmax/disruptor/RingBuffer.java#L38IIRC, Netty did similar things, and we have a whole bunch of GraalVM substitutions for that to work. See https://github.com/quarkusio/quarkus/blob/c4c8b6048b922a0873d4e4f77bcc2c0d96325a24/extensions/netty/runtime/src/main/java/io/quarkus/netty/runtime/graal/NettySubstitutions.java