diff options
8 files changed, 33 insertions, 8 deletions
diff --git a/kamon-core/src/main/scala/kamon/metric/TraceMetrics.scala b/kamon-core/src/main/scala/kamon/metric/TraceMetrics.scala index cf43b87c..eb4f327a 100644 --- a/kamon-core/src/main/scala/kamon/metric/TraceMetrics.scala +++ b/kamon-core/src/main/scala/kamon/metric/TraceMetrics.scala @@ -29,6 +29,9 @@ class TraceMetrics(instrumentFactory: InstrumentFactory) extends GenericEntityRe object TraceMetrics extends EntityRecorderFactory[TraceMetrics] { def category: String = "trace" def createRecorder(instrumentFactory: InstrumentFactory): TraceMetrics = new TraceMetrics(instrumentFactory) + + // Java API. + def factory: EntityRecorderFactory[TraceMetrics] = this } class SegmentMetrics(instrumentFactory: InstrumentFactory) extends GenericEntityRecorder(instrumentFactory) { @@ -42,4 +45,7 @@ class SegmentMetrics(instrumentFactory: InstrumentFactory) extends GenericEntity object SegmentMetrics extends EntityRecorderFactory[SegmentMetrics] { def category: String = "trace-segment" def createRecorder(instrumentFactory: InstrumentFactory): SegmentMetrics = new SegmentMetrics(instrumentFactory) + + // Java API. + def factory: EntityRecorderFactory[SegmentMetrics] = this }
\ No newline at end of file diff --git a/kamon-core/src/main/scala/kamon/util/JavaTags.scala b/kamon-core/src/main/scala/kamon/util/JavaTags.scala new file mode 100644 index 00000000..90bece5c --- /dev/null +++ b/kamon-core/src/main/scala/kamon/util/JavaTags.scala @@ -0,0 +1,14 @@ +package kamon.util + +object JavaTags { + + /** + * Helper method to transform Java maps into Scala maps. Typically this will be used as a static import from + * Java code that wants to use tags, as tags are defined as scala.collection.mutable.Map[String, String] and + * creating them directly from Java is quite verbose. + */ + def tagsFromMap(tags: java.util.Map[String, String]): Map[String, String] = { + import scala.collection.JavaConversions._ + tags.toMap + } +} diff --git a/kamon-examples/kamon-play-example/app/Global.scala b/kamon-examples/kamon-play-example/app/Global.scala index 535ea308..8d43fbdc 100644 --- a/kamon-examples/kamon-play-example/app/Global.scala +++ b/kamon-examples/kamon-play-example/app/Global.scala @@ -16,5 +16,11 @@ import filters.TraceLocalFilter import play.api.mvc.WithFilters +import play.api.Application +import kamon.Kamon -object Global extends WithFilters(TraceLocalFilter)
\ No newline at end of file +object Global extends WithFilters(TraceLocalFilter) { + override def onStart(app: Application) { + Kamon.start() + } +} diff --git a/kamon-examples/kamon-play-example/app/controllers/KamonPlayExample.scala b/kamon-examples/kamon-play-example/app/controllers/KamonPlayExample.scala index b3a8c11f..dea2b879 100644 --- a/kamon-examples/kamon-play-example/app/controllers/KamonPlayExample.scala +++ b/kamon-examples/kamon-play-example/app/controllers/KamonPlayExample.scala @@ -17,7 +17,6 @@ package controllers import filters.{TraceLocalContainer, TraceLocalKey} import kamon.Kamon -import kamon.metric.UserMetrics import kamon.play.action.TraceName import kamon.trace.TraceLocal import play.api.Logger @@ -56,7 +55,7 @@ import scala.concurrent._ object KamonPlayExample extends Controller { val logger = Logger(this.getClass) - val counter = Kamon(UserMetrics)(Akka.system()).registerCounter("my-counter") + val counter = Kamon.metrics.counter("my-counter") def sayHello = Action.async { Future { diff --git a/kamon-examples/kamon-play-example/app/filters/TraceLocalFilter.scala b/kamon-examples/kamon-play-example/app/filters/TraceLocalFilter.scala index c1d5b92e..8a92aa66 100644 --- a/kamon-examples/kamon-play-example/app/filters/TraceLocalFilter.scala +++ b/kamon-examples/kamon-play-example/app/filters/TraceLocalFilter.scala @@ -16,7 +16,7 @@ package filters -import kamon.trace.{TraceRecorder, TraceLocal} +import kamon.trace.TraceLocal import play.api.Logger import play.api.mvc.{Result, RequestHeader, Filter} import play.api.libs.concurrent.Execution.Implicits.defaultContext diff --git a/kamon-examples/kamon-play-example/conf/application.conf b/kamon-examples/kamon-play-example/conf/application.conf index 7d9fba80..e1b4d770 100644 --- a/kamon-examples/kamon-play-example/conf/application.conf +++ b/kamon-examples/kamon-play-example/conf/application.conf @@ -5,7 +5,7 @@ akka { kamon { - metrics { + metric { tick-interval = 1 second } diff --git a/kamon-examples/kamon-play-example/project/Build.scala b/kamon-examples/kamon-play-example/project/Build.scala index 080ef4a5..1896c932 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.10.4", + scalaVersion := "2.11.5", resolvers ++= resolutionRepos, scalacOptions := Seq( "-encoding", @@ -35,7 +35,7 @@ object ApplicationBuild extends Build { "-Xlog-reflective-calls" )) - val kamonVersion = "0.3.4" + val kamonVersion = "0.3.6-125bee567e0b18ea5ec10f3a1fe76409673011d9" val dependencies = Seq( "io.kamon" %% "kamon-core" % kamonVersion, diff --git a/kamon-examples/kamon-play-example/project/plugins.sbt b/kamon-examples/kamon-play-example/project/plugins.sbt index 6f7c1c8b..b4f51541 100644 --- a/kamon-examples/kamon-play-example/project/plugins.sbt +++ b/kamon-examples/kamon-play-example/project/plugins.sbt @@ -5,5 +5,5 @@ logLevel := Level.Warn 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.4") +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.8") |