aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego <diegolparra@gmail.com>2015-07-20 00:29:58 -0300
committerDiego <diegolparra@gmail.com>2015-07-20 00:29:58 -0300
commit20ebbfc8e5dd1d13ed23d63d87f7867e60896389 (patch)
treeb1f47da2509597c38239253741af858dcc77a903
parentc0a0428f0f32c77e904e4bb1be9e9d1dd801fdb1 (diff)
downloadKamon-20ebbfc8e5dd1d13ed23d63d87f7867e60896389.tar.gz
Kamon-20ebbfc8e5dd1d13ed23d63d87f7867e60896389.tar.bz2
Kamon-20ebbfc8e5dd1d13ed23d63d87f7867e60896389.zip
+ kamon-examples: update play 2.3.x example to kamon 0.4.0
-rw-r--r--kamon-examples/kamon-play-example/app/Global.scala4
-rw-r--r--kamon-examples/kamon-play-example/app/controllers/KamonPlayExample.scala2
-rw-r--r--kamon-examples/kamon-play-example/app/filters/TraceLocalFilter.scala8
-rw-r--r--kamon-examples/kamon-play-example/conf/application.conf10
-rw-r--r--kamon-examples/kamon-play-example/conf/logger.xml14
-rw-r--r--kamon-examples/kamon-play-example/project/Build.scala6
-rw-r--r--kamon-examples/kamon-play-example/project/build.properties2
-rw-r--r--kamon-examples/kamon-play-example/project/plugins.sbt3
8 files changed, 34 insertions, 15 deletions
diff --git a/kamon-examples/kamon-play-example/app/Global.scala b/kamon-examples/kamon-play-example/app/Global.scala
index 8d43fbdc..82232f24 100644
--- a/kamon-examples/kamon-play-example/app/Global.scala
+++ b/kamon-examples/kamon-play-example/app/Global.scala
@@ -23,4 +23,8 @@ object Global extends WithFilters(TraceLocalFilter) {
override def onStart(app: Application) {
Kamon.start()
}
+
+ override def onStop(app: Application) {
+ Kamon.shutdown()
+ }
}
diff --git a/kamon-examples/kamon-play-example/app/controllers/KamonPlayExample.scala b/kamon-examples/kamon-play-example/app/controllers/KamonPlayExample.scala
index dea2b879..8d0b9ff6 100644
--- a/kamon-examples/kamon-play-example/app/controllers/KamonPlayExample.scala
+++ b/kamon-examples/kamon-play-example/app/controllers/KamonPlayExample.scala
@@ -36,7 +36,7 @@ import scala.concurrent._
*
* 1- play stage
* 2- cd target/universal/stage
- * 3- java -cp ".:lib/*" -javaagent:lib/org.aspectj.aspectjweaver-1.8.1.jar play.core.server.NettyServer
+ * 3- java -cp ".:lib/*" -javaagent:lib/org.aspectj.aspectjweaver-1.8.6.jar play.core.server.NettyServer
*
* and finally for test:
*
diff --git a/kamon-examples/kamon-play-example/app/filters/TraceLocalFilter.scala b/kamon-examples/kamon-play-example/app/filters/TraceLocalFilter.scala
index 8a92aa66..1b4e1036 100644
--- a/kamon-examples/kamon-play-example/app/filters/TraceLocalFilter.scala
+++ b/kamon-examples/kamon-play-example/app/filters/TraceLocalFilter.scala
@@ -17,6 +17,7 @@
package filters
import kamon.trace.TraceLocal
+import kamon.trace.TraceLocal.{AvailableToMdc, TraceLocalKey}
import play.api.Logger
import play.api.mvc.{Result, RequestHeader, Filter}
import play.api.libs.concurrent.Execution.Implicits.defaultContext
@@ -39,16 +40,21 @@ object TraceLocalFilter extends Filter {
val logger = Logger(this.getClass)
val TraceLocalStorageKey = "MyTraceLocalStorageKey"
+ val userAgentHeader = "User-Agent"
+
+ //this value will be available in the MDC at the moment to call to Logger.*()s
+ val UserAgentHeaderAvailableToMDC = AvailableToMdc(userAgentHeader)
+
override def apply(next: (RequestHeader) ⇒ Future[Result])(header: RequestHeader): Future[Result] = {
def onResult(result:Result) = {
val traceLocalContainer = TraceLocal.retrieve(TraceLocalKey).getOrElse(TraceLocalContainer("unknown","unknown"))
- logger.info(s"traceTokenValue: ${traceLocalContainer.traceToken}")
result.withHeaders((TraceLocalStorageKey -> traceLocalContainer.traceToken))
}
//update the TraceLocalStorage
TraceLocal.store(TraceLocalKey)(TraceLocalContainer(header.headers.get(TraceLocalStorageKey).getOrElse("unknown"), "unknown"))
+ TraceLocal.store(UserAgentHeaderAvailableToMDC)(header.headers.get(userAgentHeader).getOrElse("unknown"))
//call the action
next(header).map(onResult)
diff --git a/kamon-examples/kamon-play-example/conf/application.conf b/kamon-examples/kamon-play-example/conf/application.conf
index bb9838c7..147efbcf 100644
--- a/kamon-examples/kamon-play-example/conf/application.conf
+++ b/kamon-examples/kamon-play-example/conf/application.conf
@@ -1,7 +1,4 @@
#kamon related configuration
-akka {
- extensions = ["kamon.statsd.StatsD", "kamon.system.SystemMetrics", "kamon.logreporter.LogReporter"]
-}
kamon {
@@ -42,6 +39,12 @@ kamon {
include-trace-token-header = true
trace-token-header-name = "X-Trace-Token"
}
+
+ modules {
+ kamon-statsd.auto-start = no
+ kamon-log-reporter.auto-start = yes
+ kamon-system-metrics.auto-start = no
+ }
}
# This is the main configuration file for the application.
@@ -62,4 +65,3 @@ application.langs = "en"
# Define the Global object class for this application.
# Default to Global in the root package.
# application.global=Global
-
diff --git a/kamon-examples/kamon-play-example/conf/logger.xml b/kamon-examples/kamon-play-example/conf/logger.xml
index 56b3c33e..416687bd 100644
--- a/kamon-examples/kamon-play-example/conf/logger.xml
+++ b/kamon-examples/kamon-play-example/conf/logger.xml
@@ -1,8 +1,16 @@
<configuration scan="true">
+
+ <!--
+ if we use the AsyncAppender this value will not be available at the moment of log,
+ because the operation is executed in another ThreadPool,
+ in that case we need put the value the MDC like the [%X{User-Agent}]
+ -->
+ <conversionRule conversionWord="traceToken" converterClass="kamon.trace.logging.LogbackTraceTokenConverter" />
+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
- <pattern>%date{HH:mm:ss.SSS} %-5level [%X{traceToken}][%X{importantHeader}] [%thread] %logger{55} - %msg%n</pattern>
- </encoder>
+ <pattern>%date{HH:mm:ss.SSS} %-5level [%traceToken][%X{User-Agent}] [%thread] %logger{55} - %msg%n</pattern>
+ </encoder>%traceToken
</appender>
<appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
@@ -13,7 +21,7 @@
<logger name="application" level="INFO" />
<root level="INFO">
- <appender-ref ref="ASYNC" />
+ <appender-ref ref="STDOUT" />
</root>
</configuration>
diff --git a/kamon-examples/kamon-play-example/project/Build.scala b/kamon-examples/kamon-play-example/project/Build.scala
index 1896c932..3c10e02c 100644
--- a/kamon-examples/kamon-play-example/project/Build.scala
+++ b/kamon-examples/kamon-play-example/project/Build.scala
@@ -20,7 +20,7 @@ object ApplicationBuild extends Build {
)
val defaultSettings = Seq(
- scalaVersion := "2.11.5",
+ scalaVersion := "2.11.7",
resolvers ++= resolutionRepos,
scalacOptions := Seq(
"-encoding",
@@ -35,7 +35,7 @@ object ApplicationBuild extends Build {
"-Xlog-reflective-calls"
))
- val kamonVersion = "0.3.6-125bee567e0b18ea5ec10f3a1fe76409673011d9"
+ val kamonVersion = "0.4.0"
val dependencies = Seq(
"io.kamon" %% "kamon-core" % kamonVersion,
@@ -43,7 +43,7 @@ object ApplicationBuild extends Build {
"io.kamon" %% "kamon-statsd" % kamonVersion,
"io.kamon" %% "kamon-log-reporter" % kamonVersion,
"io.kamon" %% "kamon-system-metrics" % kamonVersion,
- "org.aspectj" % "aspectjweaver" % "1.8.1"
+ "org.aspectj" % "aspectjweaver" % "1.8.6"
)
val main = Project(appName, file(".")).enablePlugins(play.PlayScala, SbtWeb)
diff --git a/kamon-examples/kamon-play-example/project/build.properties b/kamon-examples/kamon-play-example/project/build.properties
index be6c454f..a6e117b6 100644
--- a/kamon-examples/kamon-play-example/project/build.properties
+++ b/kamon-examples/kamon-play-example/project/build.properties
@@ -1 +1 @@
-sbt.version=0.13.5
+sbt.version=0.13.8
diff --git a/kamon-examples/kamon-play-example/project/plugins.sbt b/kamon-examples/kamon-play-example/project/plugins.sbt
index b4f51541..aa4d8b4c 100644
--- a/kamon-examples/kamon-play-example/project/plugins.sbt
+++ b/kamon-examples/kamon-play-example/project/plugins.sbt
@@ -1,9 +1,8 @@
// Comment to get more information during initialization
logLevel := Level.Warn
-// The Typesafe repository
+// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.8")
-