Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build for Play 3.0 #88

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
language: scala
scala:
- 2.13.0
- 2.12.8
- 2.13.8
- 3.3.0
jdk:
- openjdk8
script:
- sbt ++${TRAVIS_SCALA_VERSION} clean coverage test coverageReport
after_success:
- bash <(curl -s https://codecov.io/bash)
- bash <(curl -s https://codecov.io/bash)
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# metrics-play

This module provides some support for @codahale [Metrics](https://dropwizard.github.io/metrics/4.0.5/) library in a Play2 application (Scala)
This module provides some support for @codahale [Metrics](https://dropwizard.github.io/metrics/4.0.5/) library in a PlayFramework application (Scala)

[![Build Status](https://travis-ci.org/kenshoo/metrics-play.png)](https://travis-ci.org/kenshoo/metrics-play)

[![codecov.io](https://img.shields.io/codecov/c/gh/kenshoo/metrics-play/master.svg)](https://codecov.io/github/kenshoo/metrics-play/branch/master)

Play Version: 2.7.0, Metrics Version: 4.0.5, Scala Versions: 2.12.8
Play Version: 3.0.0, Metrics Version: 4.0.5, Scala Versions: 2.12.8

## Features

Expand All @@ -22,7 +22,7 @@ Add metrics-play dependency:
```scala
val appDependencies = Seq(
...
"com.kenshoo" %% "metrics-play" % "2.7.3_0.8.2"
"com.kenshoo" %% "metrics-play" % "3.0.0_0.8.2"
)
```

Expand All @@ -48,7 +48,7 @@ To add a custom metrics, you can use `defaultRegistry` which returns an instance

### Metrics Controller

An implementation of the [metrics-servlet](https://metrics.dropwizard.io/4.0.5/manual/servlets#metricsservlet) as a play2 controller.
An implementation of the [metrics-servlet](https://metrics.dropwizard.io/4.0.5/manual/servlets#metricsservlet) as a PlayFramework controller.

It exports all registered metrics as a json document.

Expand All @@ -71,7 +71,7 @@ Some configuration is supported through the default configuration file:

### Metrics Filter

An implementation of the Metrics' instrumenting filter for Play2. It records requests duration, number of active requests and counts each return code
An implementation of the Metrics' instrumenting filter for PlayFramework. It records requests duration, number of active requests and counts each return code


```scala
Expand Down Expand Up @@ -137,6 +137,7 @@ play.modules.enabled+="myapp.MyMetricsModule"

## Changes

* 3.0.0_0.8.2 - Upgrade to play 3.0.0 and support Scala version 2.13.8 / 3.3.0
* 2.7.3_0.8.2 - Minor compatability fix for Play 2.8
* 2.7.3_0.8.1 - Upgrade to play 2.7.3 and support Scala version 2.12.8 / 2.13.0 with dropwizard 4.0.5
* 2.7.0_0.8.0 - Upgrade to play 2.7.0 and Scala 2.12.8 and dropwizard 4.0.5
Expand Down
25 changes: 10 additions & 15 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ organization:= "com.kenshoo"

name := "metrics-play"

scalaVersion := "2.13.0"
scalaVersion := "2.13.8"

crossScalaVersions := Seq(scalaVersion.value, "2.12.8")
crossScalaVersions := Seq(scalaVersion.value, "3.3.0")

val playVersion = "2.7.3"
val playVersion = "3.0.0"

val metricsPlayVersion = "0.8.2"

Expand All @@ -17,28 +17,23 @@ version := s"${playVersion}_${metricsPlayVersion}"

scalacOptions := Seq("-unchecked", "-deprecation")

testOptions in Test += Tests.Argument("junitxml", "console")
Test / testOptions += 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.12"
Test / parallelExecution := false

resolvers += Resolver.jcenterRepo

libraryDependencies ++= Seq(
"io.dropwizard.metrics" % "metrics-core" % dropwizardVersion,
"io.dropwizard.metrics" % "metrics-json" % dropwizardVersion,
"io.dropwizard.metrics" % "metrics-jvm" % dropwizardVersion,
"io.dropwizard.metrics" % "metrics-logback" % dropwizardVersion,
"com.typesafe.play" %% "play" % playVersion % Provided,
"org.playframework" %% "play" % playVersion % Provided,
"org.joda" % "joda-convert" % "2.2.0",

//Test
"com.typesafe.play" %% "play-test" % playVersion % Test,
"com.typesafe.play" %% "play-specs2" % playVersion % Test
"org.playframework" %% "play-test" % playVersion % Test,
"org.playframework" %% "play-specs2" % playVersion % Test
)

publishMavenStyle := true
Expand All @@ -54,7 +49,7 @@ credentials += Credentials(Path.userHome / ".m2" / ".credentials")

pomIncludeRepository := { _ => false }

publishArtifact in Test := false
Test / publishArtifact := false

pomExtra := (
<url>https://github.com/kenshoo/metrics-play</url>
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.2.8
sbt.version=1.9.7
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
resolvers += Resolver.jcenterRepo

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.0")

addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2-1")
2 changes: 1 addition & 1 deletion src/main/scala/com/kenshoo/play/metrics/Metrics.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class MetricsImpl @Inject() (lifecycle: ApplicationLifecycle, configuration: Con

def defaultRegistry: MetricRegistry = SharedMetricRegistries.getOrCreate(registryName)

def setupJvmMetrics(registry: MetricRegistry) {
def setupJvmMetrics(registry: MetricRegistry): Unit = {
if (jvmMetricsEnabled) {
registry.register("jvm.attribute", new JvmAttributeGaugeSet())
registry.register("jvm.gc", new GarbageCollectorMetricSet())
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/com/kenshoo/play/metrics/MetricsFilter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package com.kenshoo.play.metrics

import javax.inject.Inject

import akka.stream.Materializer
import org.apache.pekko.stream.Materializer
import play.api.mvc._
import play.api.http.Status
import com.codahale.metrics._
Expand Down Expand Up @@ -85,4 +85,4 @@ class MetricsFilterImpl @Inject() (metrics: Metrics)(implicit val mat: Materiali
}
)
}
}
}
8 changes: 4 additions & 4 deletions src/main/scala/com/kenshoo/play/metrics/PlayModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ class PlayModule extends Module {
override def bindings(environment: Environment, configuration: Configuration): Seq[Binding[_]] = {
if (configuration.get[Boolean]("metrics.enabled")) {
Seq(
bind[MetricsFilter].to[MetricsFilterImpl].eagerly,
bind[Metrics].to[MetricsImpl].eagerly
bind[MetricsFilter].to[MetricsFilterImpl].eagerly(),
bind[Metrics].to[MetricsImpl].eagerly()
)
} else {
Seq(
bind[MetricsFilter].to[DisabledMetricsFilter].eagerly,
bind[Metrics].to[DisabledMetrics].eagerly
bind[MetricsFilter].to[DisabledMetricsFilter].eagerly(),
bind[Metrics].to[DisabledMetrics].eagerly()
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/com/kenshoo/play/metrics/MetricsSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import play.api.inject.bind
import play.api.inject.guice.GuiceApplicationBuilder
import play.api.libs.json.{Json, JsValue}
import play.api.test.Helpers._
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

class MetricsSpec extends Specification {

Expand Down