Search code examples
akkaaspectjkamon

Kamon error with configuration 'requires-aspectj'


I'm adding kamonto my standalone akka application and i'm getting this error:

com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'requires-aspectj' error at Kamon.start().

This is the relative content of application.conf.

{
...
  modules {
    kamon-akka {
      auto-start = no
    }
    kamon-statsd {
      auto-start = no
    }
    kamon-system-metric {
      auto-start = no
      requires-aspectj = no
      extension-id = "kamon.system.SystemMetrics"
    }
  }
}

application.conf: 36: requires-aspectj has type STRING rather than OBJECT

However, when I include the asked property

{
  modules {
    requires-aspectj = no
  ...
  }
}

I get this error: application.conf: 36: requires-aspectj has type STRING rather than OBJECT

If i remove Kamon.start() my application starts as usual

This is an extract of the my build.sbt:

lazy val root = (project in file("."))
  .settings(name := "kamon-akka")
  .settings(Seq(scalaVersion := "2.11.8"))
  .settings(libraryDependencies ++= Seq(
    akka.Http,
    akka.slf4jApi,
    akka.akkaSlf4j,
    kamon.Core,
    kamon.Akka,
    kamon.LogReporter,
    kamon.SystemMetrics,
    aspectj.aspectjtools,
    aspectj.aspectjweaver,
    aspectj.aspectjrt
  ))
  .settings(aspectjSettings: _*)

PS:

  • kamon = 0.6.7
  • aspectj = 1.8.9
  • sbt 0.13.13
  • scala 2.12.3
  • I'm also using this plugin addSbtPlugin("com.typesafe.sbt" % "sbt-aspectj" % "0.9.4")

any ideas?


Solution

  • First, your application.conf looks strange in that it doesn't appear to have a kamon namespace. It should look like the following (take note of the first line):

    kamon {
      ...
      modules {
        kamon-akka {
          ...
        }
        kamon-statsd {
          ...
        }
        kamon-system-metrics {
          ...
        }
      } 
    }
    

    Second, since you're using the sbt-aspectj plugin, add the following to your build.sbt (source: http://kamon.io/documentation/get-started/):

    import com.typesafe.sbt.SbtAspectj._
    
    // Bring the sbt-aspectj settings into this build
    aspectjSettings
    
    // Here we are effectively adding the `-javaagent` JVM startup
    // option with the location of the AspectJ Weaver provided by
    // the sbt-aspectj plugin.
    javaOptions in run <++= AspectjKeys.weaverOptions in Aspectj
    
    // We need to ensure that the JVM is forked for the
    // AspectJ Weaver to kick in properly and do it's magic.
    fork in run := true