Skip to content
This repository has been archived by the owner on Oct 31, 2022. It is now read-only.

Switch to using HashedWheelTimer #31

Merged
merged 1 commit into from
Aug 21, 2018
Merged
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
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ crossScalaVersions := Seq("2.11.11", "2.12.4")

organization := "com.samstarling"

val finagleVersion = "18.2.0"
val finagleVersion = "18.8.0"

libraryDependencies ++= Seq(
"com.twitter" %% "finagle-core" % finagleVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,15 @@ package com.samstarling.prometheusfinagle
import com.twitter.finagle.stats._
import io.prometheus.client.{CollectorRegistry, Summary, Counter => PCounter, Gauge => PGauge}
import scala.collection.concurrent.TrieMap

import com.twitter.finagle.util.DefaultTimer
import com.twitter.finagle.util.HashedWheelTimer
import com.twitter.util._

private object CustomDefaultTimer {
def getInstance: Timer = Option(DefaultTimer.getInstance).getOrElse(new JavaTimer(isDaemon = true))
}

class PrometheusStatsReceiver(registry: CollectorRegistry, namespace: String, timer: Timer, gaugePollInterval: Duration)
extends StatsReceiver with Closable {

def this() = this(CollectorRegistry.defaultRegistry, "finagle", CustomDefaultTimer.getInstance, Duration.fromSeconds(10))
def this() = this(CollectorRegistry.defaultRegistry, "finagle", HashedWheelTimer.Default, Duration.fromSeconds(10))

def this(registry: CollectorRegistry) = this(registry, "finagle", CustomDefaultTimer.getInstance, Duration.fromSeconds(10))
def this(registry: CollectorRegistry) = this(registry, "finagle", HashedWheelTimer.Default, Duration.fromSeconds(10))

protected val counters = TrieMap.empty[String, PCounter]
protected val summaries = TrieMap.empty[String, Summary]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import io.prometheus.client.CollectorRegistry
import java.util.concurrent.TimeUnit

class PrometheusStatsReceiverRaceTest extends UnitTest {
val threadCount = 10
val threadCount = 100
val pool = FuturePool.unboundedPool

"PrometheusStatsReceiver#counters" should {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class PrometheusStatsReceiverTest extends UnitTest {
"allow a registry, namespace, and a Timer to be passed" in {
val registry = CollectorRegistry.defaultRegistry
val namespace = "testnamespace"
new PrometheusStatsReceiver(registry, namespace, CustomDefaultTimer.getInstance, Duration.fromSeconds(1)) must not(
new PrometheusStatsReceiver(registry, namespace, DefaultTimer.twitter, Duration.fromSeconds(1)) must not(
throwA[RuntimeException])
}
}
Expand Down