aboutsummaryrefslogtreecommitdiff
path: root/kamon-examples
diff options
context:
space:
mode:
authorDiego <diegolparra@gmail.com>2014-08-05 23:58:45 -0300
committerDiego <diegolparra@gmail.com>2014-08-05 23:58:45 -0300
commit9878f62c88738ca056202f71f1725b34a109b77e (patch)
tree2e520318649c8ec867403675172442f4a5d37cf4 /kamon-examples
parent26865a62805a008f5d648cef5f64a295054ed3f5 (diff)
downloadKamon-9878f62c88738ca056202f71f1725b34a109b77e.tar.gz
Kamon-9878f62c88738ca056202f71f1725b34a109b77e.tar.bz2
Kamon-9878f62c88738ca056202f71f1725b34a109b77e.zip
+ play-example: included UserMetrics, LogReporter and SystemMetrics extensions
Diffstat (limited to 'kamon-examples')
-rw-r--r--kamon-examples/kamon-play-example/app/Global.scala7
-rw-r--r--kamon-examples/kamon-play-example/app/controllers/KamonPlayExample.scala22
-rw-r--r--kamon-examples/kamon-play-example/app/filters/TraceLocalFilter.scala4
-rw-r--r--kamon-examples/kamon-play-example/conf/application.conf26
-rw-r--r--kamon-examples/kamon-play-example/conf/routes3
-rw-r--r--kamon-examples/kamon-play-example/project/Build.scala10
6 files changed, 46 insertions, 26 deletions
diff --git a/kamon-examples/kamon-play-example/app/Global.scala b/kamon-examples/kamon-play-example/app/Global.scala
index 5fbb9c7e..535ea308 100644
--- a/kamon-examples/kamon-play-example/app/Global.scala
+++ b/kamon-examples/kamon-play-example/app/Global.scala
@@ -17,9 +17,4 @@
import filters.TraceLocalFilter
import play.api.mvc.WithFilters
-object Global extends WithFilters(TraceLocalFilter){
-
-}
-
-
-
+object Global extends WithFilters(TraceLocalFilter) \ No newline at end of file
diff --git a/kamon-examples/kamon-play-example/app/controllers/KamonPlayExample.scala b/kamon-examples/kamon-play-example/app/controllers/KamonPlayExample.scala
index 2b2e9373..7be69f6a 100644
--- a/kamon-examples/kamon-play-example/app/controllers/KamonPlayExample.scala
+++ b/kamon-examples/kamon-play-example/app/controllers/KamonPlayExample.scala
@@ -15,15 +15,18 @@
* ========================================================== */
package controllers
+import kamon.Kamon
+import kamon.metric.UserMetrics
import kamon.play.action.TraceName
import play.api.Logger
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import play.api.mvc.{Action, Controller}
+import play.libs.Akka
import scala.concurrent._
/**
- * In order to run the example we need set the -agent parameter to the JVM but Play have some limitations when trying to set an
+ * In order to run the example we need set the -javaagent option to the JVM, but Play have some limitations when trying to set an
* java agent in Play dev mode (ie, play run) -> https://github.com/playframework/playframework/issues/1372, so we have others options:
*
* The first option is set -javaagent: path-to-aspectj-weaver in your IDE or
@@ -51,8 +54,9 @@ import scala.concurrent._
object KamonPlayExample extends Controller {
val logger = Logger(this.getClass)
+ val counter = Kamon(UserMetrics)(Akka.system()).registerCounter("my-counter")
- def sayHello() = Action.async {
+ def sayHello = Action.async {
Future {
logger.info("Say hello to Kamon")
Ok("Say hello to Kamon")
@@ -60,12 +64,20 @@ object KamonPlayExample extends Controller {
}
//using the Kamon TraceName Action to rename the trace name in metrics
- def sayHelloWithTraceName() = TraceName("my-trace-name") {
+ def sayHelloWithTraceName = TraceName("my-trace-name") {
Action.async {
Future {
- logger.info("Say hello to Kamon")
- Ok("Say hello to Kamon")
+ logger.info("Say hello to Kamon with trace name")
+ Ok("Say hello to Kamon with trace name")
}
}
}
+
+ def incrementCounter = Action.async {
+ Future {
+ logger.info("increment")
+ counter.increment()
+ Ok("increment")
+ }
+ }
}
diff --git a/kamon-examples/kamon-play-example/app/filters/TraceLocalFilter.scala b/kamon-examples/kamon-play-example/app/filters/TraceLocalFilter.scala
index 08ea782c..bf496530 100644
--- a/kamon-examples/kamon-play-example/app/filters/TraceLocalFilter.scala
+++ b/kamon-examples/kamon-play-example/app/filters/TraceLocalFilter.scala
@@ -27,8 +27,8 @@ object TraceLocalKey extends TraceLocal.TraceLocalKey {
}
/*
- By default Kamon spreads the trace-token-header-name but sometimes is necessary pass through the application requests with some infomation like
- extra headers, with kamon it's possible using TraceLocalStorage, in Play applications we can do an Action Filter or using Action Composition,
+ By default kamon spreads the trace-token-header-name, but sometimes is necessary pass through the application requests with some information like
+ extra headers, with kamon it's possible using the TraceLocalStorage, in Play applications we can do an Action Filter or using Action Composition,
in this example we are using a simple filter where given a Header store the value and then put the value in the result headers..
More detailed usage of TraceLocalStorage: https://github.com/kamon-io/Kamon/blob/b17539d231da923ea854c01d2c69eb02ef1e85b1/kamon-core/src/test/scala/kamon/trace/TraceLocalSpec.scala
diff --git a/kamon-examples/kamon-play-example/conf/application.conf b/kamon-examples/kamon-play-example/conf/application.conf
index 4f9a60ec..65a834c6 100644
--- a/kamon-examples/kamon-play-example/conf/application.conf
+++ b/kamon-examples/kamon-play-example/conf/application.conf
@@ -1,11 +1,10 @@
#kamon related configuration
akka {
- extensions = ["kamon.statsd.StatsD"]
+ extensions = ["kamon.statsd.StatsD", "kamon.system.SystemMetrics", "kamon.logreporter.LogReporter"]
}
kamon {
-
- statsd {
+ statsd {
# Hostname and port in which your StatsD is running. Remember that StatsD packets are sent using UDP and
# setting unreachable hosts and/or not open ports wont be warned by the Kamon, your data wont go anywhere.
hostname = "127.0.0.1"
@@ -26,6 +25,10 @@ kamon {
dispatcher = [ "*" ]
}
+ # Enable system metrics
+ # In order to not get a ClassNotFoundException, we must register the kamon-sytem-metrics module
+ report-system-metrics = true
+
simple-metric-key-generator {
# Application prefix for all metrics pushed to StatsD. The default namespacing scheme for metrics follows
# this pattern:
@@ -33,10 +36,17 @@ kamon {
application = "kamon"
}
}
-
+
+ weaver {
+ showWeaveInfo = off
+ verbose = off
+ debug = off
+ showWarn = off
+ }
+
play {
- include-trace-token-header = true
- trace-token-header-name = "X-Trace-Token"
+ include-trace-token-header = true
+ trace-token-header-name = "X-Trace-Token"
}
}
@@ -47,11 +57,11 @@ kamon {
# ~~~~~
# The secret key is used to secure cryptographics functions.
# If you deploy your application to several instances be sure to use the same key!
-application.secret="3BLM`<aD^5r/L[MinNdw8Tp@915n0djY[g66OSOLi@?k`>AZE9EOphrmf;;6JsAN"
+application.secret = "3BLM`<aD^5r/L[MinNdw8Tp@915n0djY[g66OSOLi@?k`>AZE9EOphrmf;;6JsAN"
# The application languages
# ~~~~~
-application.langs="en"
+application.langs = "en"
# Global object class
# ~~~~~
diff --git a/kamon-examples/kamon-play-example/conf/routes b/kamon-examples/kamon-play-example/conf/routes
index 122c355a..2178c946 100644
--- a/kamon-examples/kamon-play-example/conf/routes
+++ b/kamon-examples/kamon-play-example/conf/routes
@@ -1,3 +1,4 @@
# Routes
GET /helloKamon controllers.KamonPlayExample.sayHello
-GET /helloKamonWithTraceName controllers.KamonPlayExample.sayHelloWithTraceName \ No newline at end of file
+GET /helloKamonWithTraceName controllers.KamonPlayExample.sayHelloWithTraceName
+GET /incrementCounter controllers.KamonPlayExample.incrementCounter \ No newline at end of file
diff --git a/kamon-examples/kamon-play-example/project/Build.scala b/kamon-examples/kamon-play-example/project/Build.scala
index c348862a..c9693c24 100644
--- a/kamon-examples/kamon-play-example/project/Build.scala
+++ b/kamon-examples/kamon-play-example/project/Build.scala
@@ -36,10 +36,12 @@ object ApplicationBuild extends Build {
))
val dependencies = Seq(
- "io.kamon" %% "kamon-core" % "0.3.1",
- "io.kamon" %% "kamon-play" % "0.3.1",
- "io.kamon" %% "kamon-statsd" % "0.3.1",
- "org.aspectj" % "aspectjweaver" % "1.8.1"
+ "io.kamon" %% "kamon-core" % "0.3.3",
+ "io.kamon" %% "kamon-play" % "0.3.3",
+ "io.kamon" %% "kamon-statsd" % "0.3.3",
+ "io.kamon" %% "kamon-log-reporter" % "0.3.3",
+ "io.kamon" %% "kamon-system-metrics" % "0.3.3",
+ "org.aspectj" % "aspectjweaver" % "1.8.1"
)
val main = Project(appName, file(".")).enablePlugins(play.PlayScala, SbtWeb)