Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassCastException when combining OpenTelemetry with EventBus #22597

Closed
christoph-thelen-db opened this issue Jan 3, 2022 · 1 comment · Fixed by #22615
Closed

ClassCastException when combining OpenTelemetry with EventBus #22597

christoph-thelen-db opened this issue Jan 3, 2022 · 1 comment · Fixed by #22615
Assignees
Labels
area/tracing kind/bug Something isn't working
Milestone

Comments

@christoph-thelen-db
Copy link

christoph-thelen-db commented Jan 3, 2022

Describe the bug

When trying to send a message via a vertx EventBus, the call fails because OpenTelemetry tries to cast the message into an HttpRequest.

org.jboss.resteasy.spi.UnhandledException: java.lang.ClassCastException: class io.vertx.core.eventbus.impl.MessageImpl cannot be cast to class io.vertx.core.spi.observability.HttpRequest (io.vertx.core.eventbus.impl.MessageImpl and io.vertx.core.spi.observability.HttpRequest are in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @313ac989)
        at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:105)
        at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:359)
        at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:218)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:519)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
        at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
        at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:151)
        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:91)
        at io.quarkus.vertx.core.runtime.VertxCoreRecorder$13.runWith(VertxCoreRecorder.java:543)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.ClassCastException: class io.vertx.core.eventbus.impl.MessageImpl cannot be cast to class io.vertx.core.spi.observability.HttpRequest (io.vertx.core.eventbus.impl.MessageImpl and io.vertx.core.spi.observability.HttpRequest are in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @313ac989)
        at io.quarkus.opentelemetry.runtime.tracing.vertx.OpenTelemetryVertxTracer.sendRequest(OpenTelemetryVertxTracer.java:138)
        at io.quarkus.opentelemetry.runtime.tracing.vertx.OpenTelemetryVertxTracer.sendRequest(OpenTelemetryVertxTracer.java:42)
        at io.vertx.core.eventbus.impl.OutboundDeliveryContext.next(OutboundDeliveryContext.java:125)
        at io.vertx.core.eventbus.impl.EventBusImpl.sendOrPubInternal(EventBusImpl.java:394)
        at io.vertx.core.eventbus.impl.EventBusImpl.sendOrPubInternal(EventBusImpl.java:400)
        at io.vertx.core.eventbus.impl.EventBusImpl.send(EventBusImpl.java:103)
        at io.vertx.core.eventbus.impl.EventBusImpl.send(EventBusImpl.java:97)
        at io.vertx.mutiny.core.eventbus.EventBus.send(EventBus.java:94)
        at org.acme.opentelemetry.TracedResource.hello(TracedResource.java:20)
        at org.acme.opentelemetry.TracedResource_Subclass.hello$$superforward1(Unknown Source)
        at org.acme.opentelemetry.TracedResource_Subclass$$function$$1.apply(Unknown Source)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
        at io.quarkus.resteasy.runtime.QuarkusRestPathTemplateInterceptor.restMethodInvoke(QuarkusRestPathTemplateInterceptor.java:31)
        at io.quarkus.resteasy.runtime.QuarkusRestPathTemplateInterceptor_Bean.intercept(Unknown Source)
        at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:50)
        at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)
        at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:49)
        at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(Unknown Source)
        at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
        at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
        at org.acme.opentelemetry.TracedResource_Subclass.hello(Unknown Source)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:170)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
        at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:660)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:524)
        at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:474)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:476)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:434)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:408)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:69)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:492)
        ... 15 more

Expected behavior

No exception occurs and an OpenTelemetry span is created.

Actual behavior

Call fails with a ClassCastException, see above.

How to Reproduce?

Create opentelemetry-quickstart project (see official quarkus guide for OpenTelemetry):

mvn io.quarkus.platform:quarkus-maven-plugin:2.6.1.Final:create \
    -DprojectGroupId=org.acme \
    -DprojectArtifactId=opentelemetry-quickstart \
    -DclassName="org.acme.opentelemetry.TracedResource" \
    -Dpath="/hello" \
    -Dextensions="resteasy,quarkus-opentelemetry-exporter-otlp"
cd opentelemetry-quickstart

Then add the quarkus-vertx extension to the pom.xml (see official reactive event bus guide):

    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-vertx</artifactId>
    </dependency>

Then expand the TracedResource class as follows:

@Path("/hello")
public class TracedResource {
    @Inject
    EventBus eventBus;

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String hello() {
        this.eventBus.send("bus", "Hello EventBus");
        return "Hello RESTEasy";
    }

    @ConsumeEvent("bus")
    public void onBusEvent(String msg) {
        System.out.println("Received " + msg);
    }
}

Start the application and call the endpoint. The exception is visible in the log.

Output of uname -a or ver

No response

Output of java -version

openjdk version "11.0.9" 2020-10-20 LTS

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.6.1.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739)

Additional information

No response

@christoph-thelen-db christoph-thelen-db added the kind/bug Something isn't working label Jan 3, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Jan 3, 2022

/cc @radcortez

geoand added a commit to geoand/quarkus that referenced this issue Jan 4, 2022
@geoand geoand self-assigned this Jan 4, 2022
geoand added a commit that referenced this issue Jan 4, 2022
Guard against CCE in OTel Vert.x integration
@quarkus-bot quarkus-bot bot added this to the 2.7 - main milestone Jan 4, 2022
@gsmet gsmet modified the milestones: 2.7 - main, 2.6.2.Final Jan 7, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Jan 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/tracing kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants