diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2017-06-11 16:03:53 +0200 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2017-06-11 16:03:53 +0200 |
commit | 2fdd0125c48a703bd44ff93072c859b4fc65b766 (patch) | |
tree | aa6a9022a9b093a8120213c152252b75e25e3b80 /kamon-core/src/main | |
parent | 942562d452bc1aa64ea6787702c47286c597a186 (diff) | |
download | Kamon-2fdd0125c48a703bd44ff93072c859b4fc65b766.tar.gz Kamon-2fdd0125c48a703bd44ff93072c859b4fc65b766.tar.bz2 Kamon-2fdd0125c48a703bd44ff93072c859b4fc65b766.zip |
use java.util.Duration
Diffstat (limited to 'kamon-core/src/main')
7 files changed, 14 insertions, 15 deletions
diff --git a/kamon-core/src/main/scala/kamon/Kamon.scala b/kamon-core/src/main/scala/kamon/Kamon.scala index 50124e28..f58f056e 100644 --- a/kamon-core/src/main/scala/kamon/Kamon.scala +++ b/kamon-core/src/main/scala/kamon/Kamon.scala @@ -25,7 +25,7 @@ import kamon.trace.Tracer import kamon.util.MeasurementUnit import scala.concurrent.Future -import scala.concurrent.duration.Duration +import java.time.Duration object Kamon extends MetricLookup with ReporterRegistry with io.opentracing.Tracer { diff --git a/kamon-core/src/main/scala/kamon/metric/Counter.scala b/kamon-core/src/main/scala/kamon/metric/Counter.scala index d2481fa5..043ce6e6 100644 --- a/kamon-core/src/main/scala/kamon/metric/Counter.scala +++ b/kamon-core/src/main/scala/kamon/metric/Counter.scala @@ -39,7 +39,7 @@ class LongAdderCounter(name: String, tags: Map[String, String], val unit: Measur else logger.warn(s"Ignored attempt to decrement counter [$name]") } - def snapshot(resetState: Boolean): MetricValue = + def snapshot(resetState: Boolean = true): MetricValue = if(resetState) MetricValue(name, tags, unit, adder.sumAndReset()) else diff --git a/kamon-core/src/main/scala/kamon/metric/InstrumentFactory.scala b/kamon-core/src/main/scala/kamon/metric/InstrumentFactory.scala index 2869595a..d6aa9fb9 100644 --- a/kamon-core/src/main/scala/kamon/metric/InstrumentFactory.scala +++ b/kamon-core/src/main/scala/kamon/metric/InstrumentFactory.scala @@ -23,7 +23,7 @@ import com.typesafe.config.Config import kamon.metric.InstrumentFactory.CustomInstrumentSettings import kamon.util.MeasurementUnit -import scala.concurrent.duration._ +import java.time.Duration private[kamon] class InstrumentFactory private (defaultHistogramDynamicRange: DynamicRange, defaultMMCounterDynamicRange: DynamicRange, @@ -80,14 +80,14 @@ object InstrumentFactory { val factoryConfig = config.getConfig("kamon.metric.instrument-factory") val histogramDynamicRange = readDynamicRange(factoryConfig.getConfig("default-settings.histogram")) val mmCounterDynamicRange = readDynamicRange(factoryConfig.getConfig("default-settings.min-max-counter")) - val mmCounterSampleInterval = factoryConfig.getDuration("default-settings.min-max-counter.sample-interval", TimeUnit.MILLISECONDS) + val mmCounterSampleInterval = factoryConfig.getDuration("default-settings.min-max-counter.sample-interval") val customSettings = factoryConfig.getConfig("custom-settings") .configurations .filter(nonEmptySection) .map(readCustomInstrumentSettings) - new InstrumentFactory(histogramDynamicRange, mmCounterDynamicRange, mmCounterSampleInterval.millis, customSettings) + new InstrumentFactory(histogramDynamicRange, mmCounterDynamicRange, mmCounterSampleInterval, customSettings) } private def nonEmptySection(entry: (String, Config)): Boolean = entry match { @@ -100,7 +100,7 @@ object InstrumentFactory { if (metricConfig.hasPath("lowest-discernible-value")) Some(metricConfig.getLong("lowest-discernible-value")) else None, if (metricConfig.hasPath("highest-trackable-value")) Some(metricConfig.getLong("highest-trackable-value")) else None, if (metricConfig.hasPath("significant-value-digits")) Some(metricConfig.getInt("significant-value-digits")) else None, - if (metricConfig.hasPath("sample-interval")) Some(metricConfig.getDuration("sample-interval", TimeUnit.MILLISECONDS).millis) else None + if (metricConfig.hasPath("sample-interval")) Some(metricConfig.getDuration("sample-interval")) else None ) metricName -> customSettings } diff --git a/kamon-core/src/main/scala/kamon/metric/Metric.scala b/kamon-core/src/main/scala/kamon/metric/Metric.scala index 89c0b5e9..dbac3878 100644 --- a/kamon-core/src/main/scala/kamon/metric/Metric.scala +++ b/kamon-core/src/main/scala/kamon/metric/Metric.scala @@ -23,7 +23,7 @@ import kamon.metric.InstrumentFactory.InstrumentTypes._ import kamon.util.MeasurementUnit import scala.collection.concurrent.TrieMap -import scala.concurrent.duration.Duration +import java.time.Duration diff --git a/kamon-core/src/main/scala/kamon/metric/MetricLookup.scala b/kamon-core/src/main/scala/kamon/metric/MetricLookup.scala index a09a8f02..7e58a722 100644 --- a/kamon-core/src/main/scala/kamon/metric/MetricLookup.scala +++ b/kamon-core/src/main/scala/kamon/metric/MetricLookup.scala @@ -18,7 +18,7 @@ package metric import kamon.util.MeasurementUnit -import scala.concurrent.duration.Duration +import java.time.Duration trait MetricLookup { diff --git a/kamon-core/src/main/scala/kamon/metric/MetricRegistry.scala b/kamon-core/src/main/scala/kamon/metric/MetricRegistry.scala index e47df88e..48ad29b7 100644 --- a/kamon-core/src/main/scala/kamon/metric/MetricRegistry.scala +++ b/kamon-core/src/main/scala/kamon/metric/MetricRegistry.scala @@ -24,7 +24,7 @@ import kamon.metric.InstrumentFactory.{InstrumentType, InstrumentTypes} import kamon.util.MeasurementUnit import scala.collection.concurrent.TrieMap -import scala.concurrent.duration.Duration +import java.time.Duration class MetricRegistry(initialConfig: Config) extends MetricsSnapshotGenerator { diff --git a/kamon-core/src/main/scala/kamon/metric/MinMaxCounter.scala b/kamon-core/src/main/scala/kamon/metric/MinMaxCounter.scala index 7dca3060..6acb7c54 100644 --- a/kamon-core/src/main/scala/kamon/metric/MinMaxCounter.scala +++ b/kamon-core/src/main/scala/kamon/metric/MinMaxCounter.scala @@ -16,12 +16,11 @@ package kamon.metric import java.lang.Math.abs +import java.time.Duration import java.util.concurrent.atomic.AtomicLong import kamon.util.{AtomicLongMaxUpdater, MeasurementUnit} -import scala.concurrent.duration.Duration - trait MinMaxCounter { def unit: MeasurementUnit def dynamicRange: DynamicRange @@ -35,7 +34,7 @@ trait MinMaxCounter { } class SimpleMinMaxCounter(name: String, tags: Map[String, String], underlyingHistogram: AtomicHdrHistogram, - val sampleInterval: Duration) extends MinMaxCounter{ + val sampleInterval: Duration) extends MinMaxCounter { private val min = AtomicLongMaxUpdater() private val max = AtomicLongMaxUpdater() @@ -47,9 +46,6 @@ class SimpleMinMaxCounter(name: String, tags: Map[String, String], underlyingHis def unit: MeasurementUnit = underlyingHistogram.unit - private[kamon] def snapshot(resetState: Boolean): MetricDistribution = - underlyingHistogram.snapshot(resetState) - def increment(): Unit = increment(1L) @@ -86,4 +82,7 @@ class SimpleMinMaxCounter(name: String, tags: Map[String, String], underlyingHis underlyingHistogram.record(currentMin) underlyingHistogram.record(currentMax) } + + private[kamon] def snapshot(resetState: Boolean = true): MetricDistribution = + underlyingHistogram.snapshot(resetState) } |