Kamon icon indicating copy to clipboard operation
Kamon copied to clipboard

Kamon on Lagom projects

Open tapaswenipathak opened this issue 7 years ago • 12 comments

Hello, I'm adding Kamon to a Lagom project. The logs does not have any errors but kamon isn't loading for the project. I debugged and looked a bit and found this project. Does kamon work for lagom projects? didn't find specific info for kamon on lagom in the docs or some projects on GitHub.

tapaswenipathak avatar Nov 24 '18 05:11 tapaswenipathak

I got the same problem, this was really working with pure akka based project, but not working with play and lagom. Thanks.

addSbtPlugin("com.lightbend.lagom" % "lagom-sbt-plugin" % "1.4.9")
addSbtPlugin("io.kamon" % "sbt-aspectj-runner-play-2.6" % "1.1.0")
addSbtPlugin("io.kamon" % "sbt-aspectj-runner" % "1.1.0")
addSbtPlugin("com.lightbend.sbt" % "sbt-javaagent" % "0.1.4")

"io.kamon" %% "kamon-play-2.6" % "1.0.1",

 javaAgents += "org.aspectj" % "aspectjweaver" % "1.9.2",
javaOptions += "-Dorg.aspectj.tracing.factory=default -Xset:weaveJavaxPackages=false",

kuzkdmy avatar Dec 20 '18 15:12 kuzkdmy

Contacted Kamon Team, Many thanks to @ivantopo default

kuzkdmy avatar Dec 27 '18 08:12 kuzkdmy

Just for the record, I did look into this but it is a bit more complicated than it sounds.. hope to have some more information asap!

ivantopo avatar Dec 27 '18 09:12 ivantopo

any update on this, as we want to use Lagom in production but cannot go live without distributed tracing

two10 avatar Feb 12 '19 11:02 two10

Comment from @ivantopo in Gitter:

I have seen the Play/Akka HTTP instrumentation work in Lagom applications, what doesn't work is instrumenting applications while running them on development mode.. that's a big down right there, but it doesn't mean it wont work in production mode

ihostage avatar Feb 12 '19 12:02 ihostage

You folks might also want to take a look at these messages: https://gitter.im/kamon-io/Kamon?at=5c75b7be0966d91204eef221

ivantopo avatar Feb 26 '19 22:02 ivantopo

I don't use Lagom dev mode. I can almost get Kamon to almost work in production mode (distribution created by sbt-nativepacker).

I have .enablePlugin(JavaAgent) on my app project, but this doesn't result in Kamon being initialized. If I use Kamon.init() in the application class, Kamon starts but then I see:

Error in stage [akka.http.impl.engine.server.HttpServerBluePrint$RequestTimeoutSupport@4ab2e092]: scala.util.Success cannot be cast to kamon.instrumentation.context.HasContext

I see the kanela agent being extracted to my temp dir, but I don't see a -javaagent flag in the startup script generated by sbt-nativepackager. I'm not sure at which point the agent jar is extracted to the temp dir, but it has a dynamic generated name that seems to be at odds with using -javaagent.

dpennell avatar Dec 07 '19 16:12 dpennell

I get the same error as @dpennell when running with Lagom 1.6.2 Also the setup is the same. I added the JavaAgent to the plugins and I also need to call Kamon.init() explicitly otherwise I dont see that Kanela is loaded.

leozilla avatar Jul 19 '20 15:07 leozilla

I just managed to get it working by adding javaAgents += "io.kamon" % "kanela-agent" % "1.0.6" to my build.sbt. This way I also dont need to call Kamon.init() anymore when running with prod config.

leozilla avatar Jul 19 '20 16:07 leozilla

hey @leozilla, @dpennell

I'm guessing that the plugin doesn't get triggered because of the dependency in PlayWeb from our SBT plugin.

A few months ago, I spent a couple days really trying to get this working in development mode, but I remember having major issues with the fact that in development mode there could be more than one service running on the same JVM, just with different classloaders, and not all the classloaders might have Kamon in them. Kanela, on the other side, expects having only one application per JVM and trying to resolve that clash would be a non-trivial effort.

It seems like the right thing to do is explain to people how to enable Kamon in Lagom projects in production mode and make it clear that it will just not work in dev mode. A lot of people would be happy anyways!

ivantopo avatar Jul 22 '20 12:07 ivantopo

Hello, i saw lagom instrumentation in this project and tried to add this to my lagom deployment. I added dependency (kamon-lagom) and changed value in configuration to value proposed in reference-overrides.conf. On kamon status page i see only application/lagom.persistence.dispatcher module. I saw in code that this project should add circuit brearker metrics.

It is not added to status page or i need to manually turn this metrics on?

randers-bit avatar Jan 25 '23 13:01 randers-bit

@Randerspl Yes, kamon-lagom adds only metrics for circuit breakers. For other Kamon features you need to add other Kamon modules like Play and Akka.

ihostage avatar Jan 25 '23 14:01 ihostage