Can not get Play and Kamon to play nice with AspectJ

1,119 views
Skip to first unread message

japh...@gmail.com

unread,
Oct 4, 2014, 6:19:15 PM10/4/14
to kamon...@googlegroups.com
I'm trying to get Kamon running in a play app, and getting absolutely nowhere..

I start out by creating a basic scala-play app via;
activator new test-app

I add the AspectJ plugin to plugins.sbt;
addSbtPlugin("com.typesafe.sbt" % "sbt-aspectj" % "0.10.0")

I then add the following to build.sbt;
val kamonVersion = "0.3.4"

libraryDependencies ++= Seq(
"io.kamon" %% "kamon-core" % kamonVersion,
"io.kamon" %% "kamon-statsd" % kamonVersion,
"io.kamon" %% "kamon-log-reporter" % kamonVersion,
"io.kamon" %% "kamon-system-metrics" % kamonVersion,
"org.aspectj" % "aspectjweaver" % "1.8.1"
)

aspectjSettings

javaOptions <++= AspectjKeys.weaverOptions in Aspectj

fork in run := true

In my app, I just do a really dumb val system = ActorSystem("tst") to initialize everything and send something to statsd.

I then fire it up via activator run or sbt run, and as soon as that's hit, I get the error;
It seems like your application wasn't started with the -javaagent:/path-to-aspectj-weaver.jar option. Without that Kamon might
not work properly, if you need help on setting up the weaver go to http://kamon.io/introduction/get-started/ for more info. If
you are sure that you don't need the weaver (e.g. you are only using KamonStandalone) then you can disable this error message
by changing the kamon.metrics.disable-aspectj-weaver-missing-error setting in your configuration file.

What am I missing here? I seem to have followed all the docs, but I just can't get this to work.. The test code can be found here; https://github.com/japhar81/KamonAkkaPlayTest

Thanks for the help!

Ivan Topolnjak

unread,
Oct 4, 2014, 6:22:47 PM10/4/14
to kamon...@googlegroups.com
Hello there!

Setting up the AspectJ Weaver with Play requires a bit more steps than it would for a regular application, please check out the steps [1] provided in our kamon-play-example and let us know if that works for your, regards!

[1] https://github.com/kamon-io/Kamon/blob/master/kamon-examples/kamon-play-example/app/controllers/KamonPlayExample.scala#L31

japh...@gmail.com

unread,
Oct 4, 2014, 7:54:49 PM10/4/14
to kamon...@googlegroups.com

Thanks! That started and sent stats as expected! Just wondering, does this imply there's no way to get it to work with the standard play run/test commands? If so, what are the implications when deploying to something like tomcat?

Ivan Topolnjak

unread,
Oct 5, 2014, 5:04:32 AM10/5/14
to kamon...@googlegroups.com
Well, you could try modifying your activator/play script to include the aspectj weaver and it might work properly for run/test commands, I remember that we tried that, but I'm not sure whether it works nicely or not.. you can look at [1] for a bit more of info on why we can't add agents to the play app itself from SBT.

Running on tomcat is just about adding the weaver to tomcat and that's it, but please note that we don't support servlet applications yet so you wont get Trace metrics for http requests on that deployment unless you do it manually.. still, you will get actor, dispatcher, system and user metrics as expected.

joji...@pearson.com

unread,
Oct 13, 2014, 10:21:50 AM10/13/14
to kamon...@googlegroups.com, japh...@gmail.com
Ivan,

I was also having some issues with kamon working on a Play app. I read through the comments on this - [1] https://github.com/kamon-io/Kamon/blob/master/kamon-examples/kamon-play-example/app/controllers/KamonPlayExample.scala#L31
So does it mean, regular "play run" will not work with kamon?

Thanks
Joji

japhar81

unread,
Oct 13, 2014, 11:27:32 AM10/13/14
to kamon...@googlegroups.com
I got it to kind of work by creating an sbt.sh (and activator.sh) in the local project and setting the javaagent in there, but at best that's a hack..


--
You received this message because you are subscribed to a topic in the Google Groups "kamon-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kamon-user/X7Tc6v87Dqw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kamon-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ivan Topolnjak

unread,
Oct 13, 2014, 12:16:18 PM10/13/14
to kamon...@googlegroups.com
Joji,

The aspectj weaver will not work once you are in the play/sbt console and do `play run` because of the way Play! works.. the mentioned issue [1] has an explanation from one of the Play! developers on why this special situation happens and adding the the weaver to sbt.sh/activator.sh might sound like a dirty hack but seems like the right (and only) way to do it.. let us know if you need any more help with that, regards!

[1] https://github.com/playframework/playframework/issues/1372

joji...@pearson.com

unread,
Oct 13, 2014, 1:38:54 PM10/13/14
to kamon...@googlegroups.com, japh...@gmail.com
So I tried something like this:
./activator -J-javaagent:aspectjweaver-1.7.4.jar clean compile run
and it gives me this error:
[URLClassLoader@4e18f70a] error Cannot instantiate message handler kamon.weaver.logging.KamonWeaverMessageHandler -- (ConfigException$Missing) No configuration setting found for key 'kamon'
No configuration setting found for key 'kamon'
com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'kamon'
at com.typesafe.config.impl.SimpleConfig.findKey(SimpleConfig.java:124)

If I dont specify the -J-javaagent:aspectjweaver-1.7.4.jar, then it complains that the aspectjweaver is missing

On Saturday, October 4, 2014 6:19:15 PM UTC-4, japh...@gmail.com wrote:

joji...@pearson.com

unread,
Oct 13, 2014, 1:41:19 PM10/13/14
to kamon...@googlegroups.com, japh...@gmail.com
Would you mind sharing the activator.sh that you used for this hack?

Thanks
Joji
Reply all
Reply to author
Forward
0 new messages