Skip to content
Open
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
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
language: scala
dist: trusty
scala:
- 2.11.12
- 2.12.4
- 2.12.10
- 2.13.1
jdk:
- oraclejdk8
- oraclejdk9
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Changelog

## [2.1.14] - Pending
## [2.1.16] - 2020-04-11

* Scala 2.13 support. Thanks [NeQuissimus](https://github.com/NeQuissimus)!

## [2.1.15] - 2018-04-20

## [2.1.14] - 2018-04-16

* Add test for handling floating point timer encoding
* Remove unnecessary deps and move some to test target. Thanks [travisbrown](https://github.com/travisbrown)!
Expand Down
32 changes: 20 additions & 12 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,39 @@ organization := "com.github.gphat"

name := "censorinus"

scalaVersion := "2.12.4"
crossScalaVersions := Seq("2.11.12", "2.12.4")
scalaVersion := "2.13.1"
crossScalaVersions := Seq("2.11.12", "2.12.10", "2.13.1")

scalacOptions ++= Seq(
"-encoding", "UTF-8",
"-language:_",
"-unchecked",
"-deprecation",
"-feature",
"-Xfatal-warnings",
// "-Xlint",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-Xfuture",
"-Ywarn-unused-import",
"-Ypartial-unification"
)
"-Ywarn-value-discard"
) ++ (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, x)) if x <= 12 => Seq(
"-Yno-adapted-args",
"-Ywarn-unused-import",
"-Ypartial-unification",
"-Xfuture",
"-Xfatal-warnings",
"-Xsource:2.13"
)
case _ => Seq.empty
})

resolvers ++= Seq("snapshots", "releases").map(Resolver.sonatypeRepo)

libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.5" % Test
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % Test
libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.13.5" % Test
libraryDependencies ++= Seq(
"org.scalactic" %% "scalactic" % "3.1.0" % Test,
"org.scalatest" %% "scalatest" % "3.1.0" % Test,
"org.scalatestplus" %% "scalacheck-1-14" % "3.1.0.0" % Test,
"org.scalacheck" %% "scalacheck" % "1.14.3" % Test
)

releasePublishArtifactsAction := PgpKeys.publishSigned.value

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.1.2
sbt.version=1.3.5
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.1")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.7")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13")
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")
3 changes: 2 additions & 1 deletion src/main/scala/github/gphat/censorinus/Client.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import java.util.concurrent._
import java.util.concurrent.atomic.AtomicLong
import java.util.logging.Logger

import scala.util.control.NonFatal
import scala.collection.BufferedIterator
import scala.collection.JavaConverters._
import scala.util.control.NonFatal

/** A Censorinus client! You should create one of these and reuse it across
* your application.
Expand Down
11 changes: 8 additions & 3 deletions src/test/scala/github/gphat/censorinus/ClientSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ package github.gphat.censorinus
import java.nio.ByteBuffer
import java.nio.charset.StandardCharsets
import java.util.concurrent.{CountDownLatch, LinkedBlockingQueue, TimeUnit}
import org.scalacheck.{Arbitrary, Gen}

import org.scalacheck._
import org.scalacheck.Arbitrary.arbitrary
import org.scalatest.prop.GeneratorDrivenPropertyChecks

import org.scalatest._
import org.scalatest.concurrent.Eventually
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks

import github.gphat.censorinus.statsd.Encoder

object TestSender {
Expand Down Expand Up @@ -45,7 +50,7 @@ class TestSender(val maxMessages: Int = Int.MaxValue) extends MetricSender {
def shutdown: Unit = ()
}

class ClientSpec extends FlatSpec with Matchers with Eventually with GeneratorDrivenPropertyChecks {
class ClientSpec extends AnyFlatSpec with Matchers with Eventually with ScalaCheckPropertyChecks {

"ClientSpec" should "deal with gauges" in {
val sender = new TestSender()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package github.gphat.censorinus

import org.scalatest._
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

class DogStatsDClientSpec extends FlatSpec with Matchers with BeforeAndAfter {
class DogStatsDClientSpec extends AnyFlatSpec with Matchers with BeforeAndAfter {

var client: DogStatsDClient = null

Expand Down
19 changes: 11 additions & 8 deletions src/test/scala/github/gphat/censorinus/DogStatsDEncoderSpec.scala
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
package github.gphat.censorinus

import org.scalatest._
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

import github.gphat.censorinus.dogstatsd.Encoder

class DogStatsDEncoderSpec extends FlatSpec with Matchers {
class DogStatsDEncoderSpec extends AnyFlatSpec with Matchers {

"DogStatsD Encoder" should "encode gauges" in {

val g = GaugeMetric(name = "foobar", value = 1.0, tags = Array("foo:bar"))
val g = GaugeMetric(name = "foobar", value = 1.0, tags = List("foo:bar"))
Encoder.encode(g).get should be ("foobar:1|g|#foo:bar")
}

it should "drop infinite values" in {
val g1 = GaugeMetric(name = "foobar", value = java.lang.Double.NEGATIVE_INFINITY, tags = Array("foo:bar"))
val g1 = GaugeMetric(name = "foobar", value = java.lang.Double.NEGATIVE_INFINITY, tags = List("foo:bar"))
Encoder.encode(g1) shouldBe None

val g2 = GaugeMetric(name = "foobar", value = java.lang.Double.POSITIVE_INFINITY, tags = Array("foo:bar"))
val g2 = GaugeMetric(name = "foobar", value = java.lang.Double.POSITIVE_INFINITY, tags = List("foo:bar"))
Encoder.encode(g2) shouldBe None
}

Expand Down Expand Up @@ -62,7 +65,7 @@ class DogStatsDEncoderSpec extends FlatSpec with Matchers {
it should "encode service checks" in {
val now = System.currentTimeMillis() / 1000L
val m = ServiceCheckMetric(
name = "foobar", status = DogStatsDClient.SERVICE_CHECK_OK, tags = Array("foo:bar"),
name = "foobar", status = DogStatsDClient.SERVICE_CHECK_OK, tags = List("foo:bar"),
hostname = Some("fart"), timestamp = Some(now), message = Some("wheeee")
)
Encoder.encode(m).get should be ("_sc|foobar|0|d:%d|h:fart|#foo:bar|m:wheeee".format(now))
Expand All @@ -71,7 +74,7 @@ class DogStatsDEncoderSpec extends FlatSpec with Matchers {
it should "encode service checks with newlines" in {
val now = System.currentTimeMillis() / 1000L
val m = ServiceCheckMetric(
name = "foobar", status = DogStatsDClient.SERVICE_CHECK_OK, tags = Array("foo:bar"),
name = "foobar", status = DogStatsDClient.SERVICE_CHECK_OK, tags = List("foo:bar"),
hostname = Some("fart"), timestamp = Some(now), message = Some("hello\nworld")
)
Encoder.encode(m).get should be ("_sc|foobar|0|d:%d|h:fart|#foo:bar|m:hello\\\\nworld".format(now))
Expand All @@ -80,7 +83,7 @@ class DogStatsDEncoderSpec extends FlatSpec with Matchers {
it should "encode events" in {
val now = System.currentTimeMillis() / 1000L
val m = EventMetric(
name = "foobar", text = "derp derp derp", tags = Array("foo:bar"),
name = "foobar", text = "derp derp derp", tags = List("foo:bar"),
hostname = Some("fart"), timestamp = Some(now), aggregationKey = Some("agg_key"),
priority = Some(DogStatsDClient.EVENT_PRIORITY_LOW),
sourceTypeName = Some("user"),
Expand All @@ -92,7 +95,7 @@ class DogStatsDEncoderSpec extends FlatSpec with Matchers {
it should "encode events with newlines" in {
val now = System.currentTimeMillis() / 1000L
val m = EventMetric(
name = "foobar", text = "derp derp\nderp", tags = Array("foo:bar"),
name = "foobar", text = "derp derp\nderp", tags = List("foo:bar"),
hostname = Some("fart"), timestamp = Some(now), aggregationKey = Some("agg_key"),
priority = Some(DogStatsDClient.EVENT_PRIORITY_LOW),
sourceTypeName = Some("user"),
Expand Down
5 changes: 4 additions & 1 deletion src/test/scala/github/gphat/censorinus/SamplingSpec.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package github.gphat.censorinus

import org.scalatest._
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

import github.gphat.censorinus.statsd.Encoder

class SamplingSpec extends FlatSpec with Matchers {
class SamplingSpec extends AnyFlatSpec with Matchers {

val s = new TestSender()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package github.gphat.censorinus

import org.scalatest._
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

class StatsDClientSpec extends FlatSpec with Matchers with BeforeAndAfter {
class StatsDClientSpec extends AnyFlatSpec with Matchers with BeforeAndAfter {

var client: StatsDClient = null

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package github.gphat.censorinus

import org.scalatest._
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

import github.gphat.censorinus.statsd.Encoder

class StatsDEncoderSpec extends FlatSpec with Matchers {
class StatsDEncoderSpec extends AnyFlatSpec with Matchers {

"StatsD Encoder" should "encode gauges" in {

Expand Down
5 changes: 4 additions & 1 deletion src/test/scala/github/gphat/censorinus/SynchronySpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package github.gphat.censorinus

import org.scalatest._
import org.scalatest.concurrent.Eventually
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

import github.gphat.censorinus.statsd.Encoder

class SynchronySpec extends FlatSpec with Matchers with Eventually {
class SynchronySpec extends AnyFlatSpec with Matchers with Eventually {

"Client" should "deal with gauges" in {
val s = new TestSender(1)
Expand Down
5 changes: 4 additions & 1 deletion src/test/scala/github/gphat/censorinus/UDPSenderSpec.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package github.gphat.censorinus

import org.scalatest._
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

import java.nio.ByteBuffer
import java.nio.channels.UnresolvedAddressException

class UDPSenderSpec extends FlatSpec with Matchers {
class UDPSenderSpec extends AnyFlatSpec with Matchers {

"UDPSender" should "emit errors" in {
// Guessing this port won't be used? :)
Expand Down
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := "2.1.16-SNAPSHOT"
version in ThisBuild := "2.1.16"