Skip to content

Commit

Permalink
Merge pull request #56 from kenshoo/support-play-2.5.9
Browse files Browse the repository at this point in the history
Support play 2.5.9
  • Loading branch information
Avihay Tsayeg authored Jul 6, 2017
2 parents e357480 + 125d00f commit 3368386
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: scala
scala:
- 2.11.6
- 2.10.4
- 2.11.8
jdk:
- oraclejdk8
script:
Expand Down
26 changes: 15 additions & 11 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,33 @@ organization:= "com.kenshoo"

name := "metrics-play"

version := "2.4.0_0.4.1"
version := "2.5.9_0.5.1"

scalaVersion := "2.11.6"
scalaVersion := "2.11.8"

crossScalaVersions := Seq("2.10.4", "2.11.6")
crossScalaVersions := Seq("2.11.8")

testOptions in Test += Tests.Argument("junitxml", "console")

parallelExecution in Test := false

resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"

resolvers += "specs2" at "https://mvnrepository.com/artifact/org.specs2/specs2_2.11"

libraryDependencies ++= Seq(
"io.dropwizard.metrics" % "metrics-core" % "3.1.2",
"io.dropwizard.metrics" % "metrics-json" % "3.1.2",
"io.dropwizard.metrics" % "metrics-jvm" % "3.1.2",
"io.dropwizard.metrics" % "metrics-logback" % "3.1.2",
"com.typesafe.play" %% "play" % "2.4.0" % "provided",
"io.dropwizard.metrics" % "metrics-core" % "3.2.2",
"io.dropwizard.metrics" % "metrics-json" % "3.2.2",
"io.dropwizard.metrics" % "metrics-jvm" % "3.2.2",
"io.dropwizard.metrics" % "metrics-logback" % "3.2.2",
"com.typesafe.play" %% "play" % "2.5.9" % "provided",
"org.joda" % "joda-convert" % "1.2",
//test
"com.typesafe.play" %% "play-test" % "2.4.0" % "test",
"com.typesafe.play" %% "play-specs2" % "2.4.0" % "test",
"org.specs2" %% "specs2" % "2.3.12" % "test"
"com.typesafe.play" %% "play-test" % "2.5.9" % "test",
"com.typesafe.play" %% "play-specs2" % "2.5.9" % "test",
"org.specs2" %% "specs2" % "2.4.15" % "test"
)

publishMavenStyle := true
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/com/kenshoo/play/metrics/MetricsFilter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ package com.kenshoo.play.metrics

import javax.inject.Inject

import akka.stream.Materializer
import play.api.mvc._
import play.api.http.Status
import play.api.libs.concurrent.Execution.Implicits.defaultContext

import com.codahale.metrics._
import com.codahale.metrics.MetricRegistry.name

Expand All @@ -29,13 +29,13 @@ import scala.concurrent.Future

trait MetricsFilter extends Filter

class DisabledMetricsFilter @Inject() extends MetricsFilter {
class DisabledMetricsFilter @Inject()(implicit val mat: Materializer) extends MetricsFilter {
def apply(nextFilter: (RequestHeader) => Future[Result])(rh: RequestHeader): Future[Result] = {
nextFilter(rh)
}
}

class MetricsFilterImpl @Inject() (metrics: Metrics) extends MetricsFilter {
class MetricsFilterImpl @Inject() (metrics: Metrics)(implicit val mat: Materializer) extends MetricsFilter {

def registry: MetricRegistry = metrics.defaultRegistry

Expand Down
6 changes: 3 additions & 3 deletions src/test/scala/com/kenshoo/play/metrics/MetricsSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ class MetricsSpec extends Specification {

"serialize to JSON" in withApplication(Map.empty) { implicit app =>
val jsValue: JsValue = Json.parse(metrics.toJson)
(jsValue \ "version").as[String] mustEqual "3.0.0"
(jsValue \ "version").as[String] mustEqual "3.1.3"
}

"be able to add custom counter" in withApplication(Map.empty) { implicit app =>
"be able to add custom counter" in withApplication(Map("metrics.jvm" -> false)) { implicit app =>
metrics.defaultRegistry.counter("my-counter").inc()

val jsValue: JsValue = Json.parse(metrics.toJson)
(jsValue \ "counters" \ "my-counter" \ "count").as[Int] mustEqual(1)
}

"contain JVM metrics" in withApplication(Map.empty) { implicit app =>
"contain JVM metrics" in withApplication(Map("metrics.jvm" -> true)) { implicit app =>
metrics.defaultRegistry.getGauges.asScala must haveKey("jvm.attribute.name")
}

Expand Down

0 comments on commit 3368386

Please sign in to comment.