diff options
author | Ivan Topolnak <itopolnak@despegar.com> | 2014-03-07 18:08:01 -0300 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2014-03-11 21:14:53 -0300 |
commit | b6af84ab6b60b4ca6c0389c8c3622db3d3c27915 (patch) | |
tree | 1f89896820e36d59daadef7699b434de1051be42 /kamon-playground/src/main | |
parent | ccbcc55282251b5e6d4f41384730232a8f0e7d05 (diff) | |
download | Kamon-b6af84ab6b60b4ca6c0389c8c3622db3d3c27915.tar.gz Kamon-b6af84ab6b60b4ca6c0389c8c3622db3d3c27915.tar.bz2 Kamon-b6af84ab6b60b4ca6c0389c8c3622db3d3c27915.zip |
multiple fixes to the custom metrics collection facilities
Diffstat (limited to 'kamon-playground/src/main')
-rw-r--r-- | kamon-playground/src/main/resources/application.conf | 10 | ||||
-rw-r--r-- | kamon-playground/src/main/scala/test/SimpleRequestProcessor.scala | 13 |
2 files changed, 18 insertions, 5 deletions
diff --git a/kamon-playground/src/main/resources/application.conf b/kamon-playground/src/main/resources/application.conf index f0698592..97785275 100644 --- a/kamon-playground/src/main/resources/application.conf +++ b/kamon-playground/src/main/resources/application.conf @@ -1,6 +1,6 @@ akka { loggers = [ "akka.event.slf4j.Slf4jLogger" ] - loglevel = INFO + loglevel = DEBUG extensions = ["kamon.newrelic.NewRelic"] @@ -20,7 +20,7 @@ spray.can { kamon { newrelic { app-name = "SimpleRequestProcessor" - license-key = e7d350b14228f3d28f35bc3140df2c3e565ea5d5 + license-key = 2e24765acb032cb9e7207013b5ba3e2ab7d2d75c } } @@ -46,6 +46,12 @@ kamon { includes = [ "default-dispatcher" ] excludes = [] } + }, + { + custom-metric { + includes = [ "*" ] + excludes = [ ] + } } ] } diff --git a/kamon-playground/src/main/scala/test/SimpleRequestProcessor.scala b/kamon-playground/src/main/scala/test/SimpleRequestProcessor.scala index dfa275ba..9ff22c12 100644 --- a/kamon-playground/src/main/scala/test/SimpleRequestProcessor.scala +++ b/kamon-playground/src/main/scala/test/SimpleRequestProcessor.scala @@ -26,7 +26,7 @@ import scala.util.Random import akka.routing.RoundRobinRouter import kamon.trace.TraceRecorder import kamon.Kamon -import kamon.metrics.{ TickMetricSnapshotBuffer, ActorMetrics, TraceMetrics, Metrics } +import kamon.metrics._ import spray.http.{ StatusCodes, Uri } import kamon.metrics.Subscriptions.TickMetricSnapshot import kamon.newrelic.WebTransactionMetrics @@ -45,9 +45,9 @@ object SimpleRequestProcessor extends App with SimpleRoutingApp with RequestBuil def receive: Actor.Receive = { case any ⇒ sender ! any } }), "com") - val buffer = system.actorOf(TickMetricSnapshotBuffer.props(10 seconds, printer)) + //val buffer = system.actorOf(TickMetricSnapshotBuffer.props(30 seconds, printer)) - Kamon(Metrics).subscribe(TraceMetrics, "*", buffer, permanently = true) + //Kamon(Metrics).subscribe(CustomMetric, "*", buffer, permanently = true) //Kamon(Metrics).subscribe(ActorMetrics, "*", printer, permanently = true) implicit val timeout = Timeout(30 seconds) @@ -55,6 +55,9 @@ object SimpleRequestProcessor extends App with SimpleRoutingApp with RequestBuil val pipeline = sendReceive val replier = system.actorOf(Props[Replier].withRouter(RoundRobinRouter(nrOfInstances = 2)), "replier") val random = new Random() + + val requestCountRecorder = Kamon(Metrics).register(CustomMetric("GetCount"), CustomMetric.histogram(10, 3, Scale.Unit)) + startServer(interface = "localhost", port = 9090) { get { path("test") { @@ -85,6 +88,8 @@ object SimpleRequestProcessor extends App with SimpleRoutingApp with RequestBuil path("ok") { traceName("OK") { complete { + println("Defined: " + requestCountRecorder) + requestCountRecorder.map(_.record(1)) "ok" } } @@ -115,6 +120,8 @@ object SimpleRequestProcessor extends App with SimpleRoutingApp with RequestBuil class PrintWhatever extends Actor { def receive = { + case TickMetricSnapshot(from, to, metrics) ⇒ + println(metrics.map { case (key, value) ⇒ key.name + " => " + value.metrics.mkString(",") }.mkString("|")) case anything ⇒ println(anything) } } |