Skip to content

Instantly share code, notes, and snippets.

@ivantopo
Created April 21, 2016 11:56
Show Gist options
  • Save ivantopo/67a73a5952ce526d3fd051224c4d5ca3 to your computer and use it in GitHub Desktop.
Save ivantopo/67a73a5952ce526d3fd051224c4d5ca3 to your computer and use it in GitHub Desktop.
vicaba-example
kamon {
metric {
tick-interval = 5 second
filters {
akka-actor {
includes = [ "**" ]
}
akka-dispatcher {
includes = [ "**" ]
}
akka-router {
includes = [ "**" ]
}
}
}
system-metrics {
#sigar is enabled by default
sigar-enabled = true
#jmx related metrics are enabled by default
jmx-enabled = true
}
}
scalaVersion := "2.11.8"
name := "vicaba-example"
val kamonVersion = "0.6.0"
libraryDependencies ++= Seq(
"io.kamon" % "kamon-core_2.11" % kamonVersion,
"io.kamon" % "kamon-log-reporter_2.11" % kamonVersion,
"io.kamon" % "kamon-system-metrics_2.11" % kamonVersion,
"com.typesafe.akka" %% "akka-actor" % "2.4.1",
"com.typesafe.akka" %% "akka-slf4j" % "2.4.1",
"io.kamon" % "kamon-akka_2.11" % kamonVersion
)
aspectjSettings
javaOptions in run <++= AspectjKeys.weaverOptions in Aspectj
fork in run := true
package kamontest
import akka.actor.{Props, ActorSystem, Actor}
import kamon.Kamon
import kamon.metric.SubscriptionsDispatcher.TickMetricSnapshot
object Main {
def main(args: Array[String]) {
Kamon.start()
val system = ActorSystem()
val subscriber = system.actorOf(Props(SimplePrinter()))
Kamon.metrics.subscribe("akka-actor", "**", subscriber, permanently = true)
Kamon.metrics.subscribe("akka-router", "**", subscriber, permanently = true)
Kamon.metrics.subscribe("akka-dispatcher", "**", subscriber, permanently = true)
Thread.sleep(30000)
// This application wont terminate unless you shutdown Kamon.
Kamon.shutdown()
}
}
case class SimplePrinter() extends Actor {
def receive = {
case tickSnapshot: TickMetricSnapshot =>
println(tickSnapshot.metrics.filterKeys(_ => true))
}
}
addSbtPlugin("com.typesafe.sbt" % "sbt-aspectj" % "0.10.6")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment