diff options
Diffstat (limited to 'kamon-core/src/main')
4 files changed, 6 insertions, 6 deletions
diff --git a/kamon-core/src/main/scala/kamon/trace/Incubator.scala b/kamon-core/src/main/scala/kamon/trace/Incubator.scala index 05279d95..5ee91a4b 100644 --- a/kamon-core/src/main/scala/kamon/trace/Incubator.scala +++ b/kamon-core/src/main/scala/kamon/trace/Incubator.scala @@ -24,6 +24,7 @@ import scala.collection.immutable.Queue import kamon.util.ConfigTools.Syntax class Incubator(subscriptions: ActorRef) extends Actor with ActorLogging { + import kamon.util.ConfigTools.Syntax import context.dispatcher val config = context.system.settings.config.getConfig("kamon.trace.incubator") diff --git a/kamon-core/src/main/scala/kamon/trace/Sampler.scala b/kamon-core/src/main/scala/kamon/trace/Sampler.scala index 5abba221..827840d7 100644 --- a/kamon-core/src/main/scala/kamon/trace/Sampler.scala +++ b/kamon-core/src/main/scala/kamon/trace/Sampler.scala @@ -17,6 +17,7 @@ package kamon.trace import kamon.util.{ NanoInterval, Sequencer } +import scala.concurrent.duration.FiniteDuration import scala.concurrent.forkjoin.ThreadLocalRandom trait Sampler { @@ -64,10 +65,9 @@ object OrderedSampler { } } -class ThresholdSampler(thresholdInNanoseconds: Long) extends Sampler { - require(thresholdInNanoseconds > 0, "kamon.trace.threshold-sampler.minimum-elapsed-time cannot be <= 0") +class ThresholdSampler(threshold: FiniteDuration) extends Sampler { def shouldTrace: Boolean = true - def shouldReport(traceElapsedTime: NanoInterval): Boolean = traceElapsedTime.nanos >= thresholdInNanoseconds + def shouldReport(traceElapsedTime: NanoInterval): Boolean = traceElapsedTime.nanos >= threshold.toNanos } diff --git a/kamon-core/src/main/scala/kamon/trace/TracerExtensionSettings.scala b/kamon-core/src/main/scala/kamon/trace/TracerExtensionSettings.scala index 6167a007..739bbefc 100644 --- a/kamon-core/src/main/scala/kamon/trace/TracerExtensionSettings.scala +++ b/kamon-core/src/main/scala/kamon/trace/TracerExtensionSettings.scala @@ -16,7 +16,6 @@ package kamon.trace -import java.util.concurrent.TimeUnit import kamon.util.ConfigTools.Syntax import com.typesafe.config.Config @@ -38,7 +37,7 @@ object TraceSettings { case "all" ⇒ SampleAll case "random" ⇒ new RandomSampler(tracerConfig.getInt("random-sampler.chance")) case "ordered" ⇒ new OrderedSampler(tracerConfig.getInt("ordered-sampler.interval")) - case "threshold" ⇒ new ThresholdSampler(tracerConfig.getFiniteDuration("threshold-sampler.minimum-elapsed-time").toNanos) + case "threshold" ⇒ new ThresholdSampler(tracerConfig.getFiniteDuration("threshold-sampler.minimum-elapsed-time")) } TraceSettings(detailLevel, sampler) diff --git a/kamon-core/src/main/scala/kamon/util/ConfigTools.scala b/kamon-core/src/main/scala/kamon/util/ConfigTools.scala index bcec22c3..483278bf 100644 --- a/kamon-core/src/main/scala/kamon/util/ConfigTools.scala +++ b/kamon-core/src/main/scala/kamon/util/ConfigTools.scala @@ -28,7 +28,7 @@ object ConfigTools { // versions of Akka using older typesafe-config versions. def getFiniteDuration(path: String): FiniteDuration = - FiniteDuration(config.getDuration(path, TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS) + FiniteDuration(config.getNanoseconds(path), TimeUnit.NANOSECONDS) def firstLevelKeys: Set[String] = { import scala.collection.JavaConverters._ |