You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to replicate the work discussed https://github.com/kamon-io/Kamon/discussions/878, but instead use Java and Play Framework (I am currently trying to reduce this to a very simple example, so if you need the code, I can provide). The idea is to emit the span data to logs (would appreciate help in this area if my approach is wrong).
I have added this to my application.conf:
kamon {
modules {
my-log-reporter {
enabled = true,
name = "Log-reporter",
description = "Send to log"
factory = "common.util.KamonLogReporterFactory"
}
}
trace.tick-interval = 1 second
trace.sampler = always
}
And have created the class. At runtime (sbt run), I can see that the module fails to be imported:
[warn] k.m.ModuleRegistry - Failed to create instance of module [Log-reporter]
java.lang.ClassNotFoundException: common.util..KamonLogReporterFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
at kamon.instrumentation.sbt.KanelaOnSystemClassLoader.loadClass(KanelaOnSystemClassLoader.java:31)
at kamon.instrumentation.sbt.play.SbtKanelaRunnerPlay$SbtKanelaClassLoader.loadClass(SbtKanelaRunnerPlay.scala:76)
at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at kamon.util.DynamicAccess.getClassFor(DynamicAccess.scala:37)
I was a bit baffled by this, so I added this to my Module.java:
[info] compiling 2 Java sources to /Users/cdavid/code/test/otel/play-samples/play-java-rest-api-example/target/scala-2.13/classes ...
[error] Module - AAAAA
[error] Module - FOUND IT!
[info] p.a.d.DefaultDBApi - Database [default] initialized
[info] p.a.d.HikariCPConnectionPool - Creating Pool for datasource 'default'
[info] p.a.d.HikariCPConnectionPool - datasource [default] bound to JNDI as DefaultDS
[info] a.e.s.Slf4jLogger - Slf4jLogger started
[warn] k.m.ModuleRegistry - Failed to create instance of module [Log-reporter]
java.lang.ClassNotFoundException: common.util.KamonLogReporterFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
at kamon.instrumentation.sbt.KanelaOnSystemClassLoader.loadClass(KanelaOnSystemClassLoader.java:33)
at kamon.instrumentation.sbt.play.SbtKanelaRunnerPlay$SbtKanelaClassLoader.loadClass(SbtKanelaRunnerPlay.scala:76)
at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at kamon.util.DynamicAccess.getClassFor(DynamicAccess.scala:37)
at kamon.util.DynamicAccess.createInstanceFor(DynamicAccess.scala:60)
at kamon.ClassLoading.createInstance(ClassLoading.scala:58)
I am suspecting some weird interaction between Play Framework and Kamon/Kanela - somehow, the libraries in the Play Framework are not available, but I don't know enough to tell exactly what is going on. Would appreciate suggestions on solving the original problem if there are better ways to do it.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi
I am trying to replicate the work discussed https://github.com/kamon-io/Kamon/discussions/878, but instead use Java and Play Framework (I am currently trying to reduce this to a very simple example, so if you need the code, I can provide). The idea is to emit the span data to logs (would appreciate help in this area if my approach is wrong).
I have added this to my application.conf:
And have created the class. At runtime (
sbt run
), I can see that the module fails to be imported:I was a bit baffled by this, so I added this to my
Module.java
:and the class is found:
I am suspecting some weird interaction between Play Framework and Kamon/Kanela - somehow, the libraries in the Play Framework are not available, but I don't know enough to tell exactly what is going on. Would appreciate suggestions on solving the original problem if there are better ways to do it.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions