kamon-io / Kamon

Distributed Tracing, Metrics and Context Propagation for applications running on the JVM
https://kamon.io
Other
1.41k stars 328 forks source link

ClassCastException when using Slick and Kamon Jdbc #1331

Open alexmihailov opened 8 months ago

alexmihailov commented 8 months ago

Kamon version 2.6.1 Kanela version 1.0.17 Slick version 3.3.2

When using Slick and Kamon Jdbc with setting: kanela.modules.executor-service-capture-on-submit setup.enabled = true

I get an exception:

java.lang.ClassCastException: class kamon.instrumentation.executor.CaptureContextOnSubmitInstrumentation$ContextAwareRunnable cannot be cast to class slick.util.AsyncExecutor$PrioritizedRunnable (kamon.instrumentation.executor.CaptureContextOnSubmitInstrumentation$ContextAwareRunnable and slick.util.AsyncExecutor$PrioritizedRunnable are in unnamed module of loader 'app')
    at slick.util.ManagedArrayBlockingQueue.offer(ManagedArrayBlockingQueue.scala:17)
    at java.base/java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1347)
    at slick.util.AsyncExecutor$$anon$1$$anon$4.execute(AsyncExecutor.scala:163)
    at scala.concurrent.impl.Promise$Transformation.submitWithValue(Promise.scala:429)
    at scala.concurrent.impl.Promise$DefaultPromise.submitWithValue(Promise.scala:338)
    at scala.concurrent.impl.Promise$DefaultPromise.dispatchOrAddCallbacks(Promise.scala:312)
    at scala.concurrent.impl.Promise$DefaultPromise.map(Promise.scala:182)
    at scala.concurrent.Future$.apply(Future.scala:678)
    at slick.jdbc.JdbcBackend$DatabaseDef.io(JdbcBackend.scala:65)

Also, to reproduce the error, it is necessary that HicariCP did not immediately process the tasks, but queued them by calling the java.util.concurrent method.BlockingQueue.offer(E).

I created an example in which I described the error in more detail and reproduced it - https://github.com/alexmihailov/kamon-slick-issue