javascalaakkatelemetrycinnamon

Lightbend telemetry gets triggered only when executing the program via terminal


I am trying to develop an Akka application using Scala and I would like to log the application behavior using Lightbend Telemetry: Cinnamon Grafana + Prometheus.

I set up everything with sbt following this tutorial https://developer.lightbend.com/docs/telemetry/current//setup/cinnamon-agent-sbt.html

Eveything works well, but Cinnamon only starts when I run my application from command line using

sbt clean compile
sbt run

And I can see the logs in the console

[info] [INFO] [02/14/2022 10:58:15.480] [main-1] [Cinnamon] Agent version 2.16.2
[info] [INFO] [02/14/2022 10:58:16.362] [main-1] [Cinnamon] Agent found Java Futures version: 1.8.0_311
[info] [INFO] [02/14/2022 10:58:16.436] [main-1] [Cinnamon] Agent found Scala version: 2.13.8
[info] [INFO] [02/14/2022 10:58:16.436] [main-1] [Cinnamon] Agent found Scala Futures version: 2.13.8

When I run it from IntelliJ (run) or when I build the fat jar through set-assembly and run it with java -jar, Cinnamon does not start.

Anyone that can help me understanding why?


Solution

  • It boils down to passing -javaagent switch when starting jvm.

    sbt can do it for you when you run the app via sbt run. When you run it from intellij or packaged jar, that switch is not passed to jvm and therefore the Cinnamon is not running.

    In intellij you can go to run configuration and add the -javaagent path/to/cinnamon-agent.jar in config. if you run your jar via java jar your-jar.jar just add the switch to command line.