在 Play 应用程序中配置 Kamon 和 AspectjWeaver

Configure Kamon and AspectjWeaver in Play application

我正在尝试配置播放应用程序以使用 Kamon。我使用

创建了一个新的播放应用程序
activator new kamon-play play-scala

那我posted it on github. I'm running on OS X 10.11.1 and I'm running JDK 1.8.0_65-b17 and the project is configured with scala 2.11.6. I've configured it (to the best of my understanding) based on the instructions for configuring Play as well as the sbt-aspectj-runner kamon-play example。但是,当我尝试 运行 使用以下任一应用程序时:

sbt run

activator run

我收到以下错误:

[ERROR] [11/25/2015 09:04:39.574] [ForkJoinPool-1-worker-9] [ModuleLoader(akka://kamon)] 

  ___                           _      ___   _    _                                 ___  ___ _            _
 / _ \                         | |    |_  | | |  | |                                |  \/  |(_)          (_)
/ /_\ \ ___  _ __    ___   ___ | |_     | | | |  | |  ___   __ _ __   __ ___  _ __  | .  . | _  ___  ___  _  _ __    __ _
|  _  |/ __|| '_ \  / _ \ / __|| __|    | | | |/\| | / _ \ / _` |\ \ / // _ \| '__| | |\/| || |/ __|/ __|| || '_ \  / _` |
| | | |\__ \| |_) ||  __/| (__ | |_ /\__/ / \  /\  /|  __/| (_| | \ V /|  __/| |    | |  | || |\__ \__ \| || | | || (_| |
\_| |_/|___/| .__/  \___| \___| \__|\____/   \/  \/  \___| \__,_|  \_/  \___||_|    \_|  |_/|_||___/|___/|_||_| |_| \__, |
            | |                                                                                                      __/ |
            |_|                                                                                                     |___/

 It seems like your application was not started with the -javaagent:/path-to-aspectj-weaver.jar option but Kamon detected
 the following modules which require AspectJ to work properly:

      kamon-akka, kamon-scala, kamon-play

 If you need help on setting up the aspectj weaver go to http://kamon.io/introduction/get-started/ for more info. On the
 other hand, if you are sure that you do not need or do not want to use the weaver then you can disable this error message
 by changing the kamon.show-aspectj-missing-warning setting in your configuration file.

我已经尝试了以下所有方法:

但这会导致以下错误:

Error opening zip file or JAR manifest missing : :~/.ivy2/cache/org.aspectj/aspectjweaver/jars/aspectjweaver-1.8.5.jar
Error occurred during initialization of VM
agent library failed to init: instrument

也试过

sbt run -Djavaagent:~/.ivy2/cache/org.aspectj/aspectjweaver/jars/aspectjweaver-1.8.5.jar -Daspectj-play-runner:run

更新

我发现 aspectj-play-运行ner:运行 是一个 sbt task/command 所以我试了一下:

sbt
aspectj-runner:run

输出:

[WeavingURLClassLoader] warning javax.* types are not being woven because the weaver option '-Xset:weaveJavaxPackages=true' has not been specified
java.lang.RuntimeException: Kamon has not been started yet. You must either explicitlt call Kamon.start(...) or enable automatic startup by adding -Dkamon.auto-start=true to your JVM options.

然后我尝试了:

sbt -Dkamon.auto-start=true
aspectj-runner:run

输出:

[WeavingURLClassLoader] warning javax.* types are not being woven because the weaver option '-Xset:weaveJavaxPackages=true' has not been specified
com.typesafe.config.ConfigException$IO: application.conf: java.io.IOException: resource not found on classpath: application.conf

最后,文件实际上说我应该 运行ning

sbt
aspectj-play-runner:run

但是 command/task 甚至无法识别。

我可以在推特上联系@kamonteam,这是他们的回复:

@dvMENTALmadness currently we have a bug in kamon when using the akka and play modules together, until next release that we hope do in...... the weekend for now the only option is remove the kamon-akka module :(

基于此,我从 build.sbt 和 application.config 中删除了对 kamon-akka 模块的引用,现在它可以正常工作了。一旦我从项目中遇到问题 # 我将跟踪它并在问题解决后 post 。与此同时,here's the commit "fixed" 对我来说是个问题。但是,我仍然需要 akka 模块,因为它对我来说是一个完整的解决方案。

一种解决方法是设置 JAVA_OPTS 环境变量。

export JAVA_OPTS="-javaagent:$HOME/.ivy2/cache/org.aspectj/aspectjweaver/jars/aspectjweaver-1.8.10.jar"
sbt run