kamon-io / Kamon

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

Kamon on Lagom projects #563

Open tapaswenipathak opened 6 years ago

tapaswenipathak commented 6 years ago

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.

kuzkdmy commented 5 years ago

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 commented 5 years ago

Contacted Kamon Team, Many thanks to @ivantopo

default
ivantopo commented 5 years ago

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!

two10 commented 5 years ago

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

ihostage commented 5 years ago

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

ivantopo commented 5 years ago

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

dpennell commented 4 years ago

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.

leozilla commented 4 years ago

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 commented 4 years ago

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.

ivantopo commented 4 years ago

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!

randers-bit commented 1 year ago

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?

ihostage commented 1 year ago

@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.