diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2017-06-06 14:15:15 +0200 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2017-06-06 14:15:15 +0200 |
commit | c52f8eaca0d1ccc4c992cba039e35e099b5b478b (patch) | |
tree | f9e78e2f929627e7547bef39fdf6cbcd544cb8d8 /kamon-core/src/legacy-main/scala/kamon/metric/instrument/InstrumentSettings.scala | |
parent | 1f5d9876dedb715ae1c31203ea4f15ebf031612c (diff) | |
download | Kamon-c52f8eaca0d1ccc4c992cba039e35e099b5b478b.tar.gz Kamon-c52f8eaca0d1ccc4c992cba039e35e099b5b478b.tar.bz2 Kamon-c52f8eaca0d1ccc4c992cba039e35e099b5b478b.zip |
make it compile for Scala 2.11 and 2.12
Diffstat (limited to 'kamon-core/src/legacy-main/scala/kamon/metric/instrument/InstrumentSettings.scala')
-rw-r--r-- | kamon-core/src/legacy-main/scala/kamon/metric/instrument/InstrumentSettings.scala | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/kamon-core/src/legacy-main/scala/kamon/metric/instrument/InstrumentSettings.scala b/kamon-core/src/legacy-main/scala/kamon/metric/instrument/InstrumentSettings.scala deleted file mode 100644 index e4d6f547..00000000 --- a/kamon-core/src/legacy-main/scala/kamon/metric/instrument/InstrumentSettings.scala +++ /dev/null @@ -1,73 +0,0 @@ -package kamon.metric.instrument - -import com.typesafe.config.Config -import kamon.metric.instrument.Histogram.DynamicRange - -import scala.concurrent.duration.FiniteDuration - -case class InstrumentCustomSettings(lowestDiscernibleValue: Option[Long], highestTrackableValue: Option[Long], - precision: Option[Int], refreshInterval: Option[FiniteDuration]) { - - def combine(that: InstrumentSettings): InstrumentSettings = - InstrumentSettings( - DynamicRange( - lowestDiscernibleValue.getOrElse(that.dynamicRange.lowestDiscernibleValue), - highestTrackableValue.getOrElse(that.dynamicRange.highestTrackableValue), - precision.getOrElse(that.dynamicRange.precision) - ), - refreshInterval.orElse(that.refreshInterval) - ) -} - -object InstrumentCustomSettings { - import kamon.util.ConfigTools.Syntax - - def fromConfig(config: Config): InstrumentCustomSettings = - InstrumentCustomSettings( - if (config.hasPath("lowest-discernible-value")) Some(config.getLong("lowest-discernible-value")) else None, - if (config.hasPath("highest-trackable-value")) Some(config.getLong("highest-trackable-value")) else None, - if (config.hasPath("precision")) Some(InstrumentSettings.parsePrecision(config.getString("precision"))) else None, - if (config.hasPath("refresh-interval")) Some(config.getFiniteDuration("refresh-interval")) else None - ) - -} - -case class InstrumentSettings(dynamicRange: DynamicRange, refreshInterval: Option[FiniteDuration]) - -object InstrumentSettings { - - def readDynamicRange(config: Config): DynamicRange = - DynamicRange( - config.getLong("lowest-discernible-value"), - config.getLong("highest-trackable-value"), - parsePrecision(config.getString("precision")) - ) - - def parsePrecision(stringValue: String): Int = stringValue match { - case "low" ⇒ 1 - case "normal" ⇒ 2 - case "fine" ⇒ 3 - case other ⇒ sys.error(s"Invalid precision configuration [$other] found, valid options are: [low|normal|fine].") - } -} - -case class DefaultInstrumentSettings(histogram: InstrumentSettings, minMaxCounter: InstrumentSettings, gauge: InstrumentSettings) - -object DefaultInstrumentSettings { - - def fromConfig(config: Config): DefaultInstrumentSettings = { - import kamon.util.ConfigTools.Syntax - - val histogramSettings = InstrumentSettings(InstrumentSettings.readDynamicRange(config.getConfig("histogram")), None) - val minMaxCounterSettings = InstrumentSettings( - InstrumentSettings.readDynamicRange(config.getConfig("min-max-counter")), - Some(config.getFiniteDuration("min-max-counter.refresh-interval")) - ) - val gaugeSettings = InstrumentSettings( - InstrumentSettings.readDynamicRange(config.getConfig("gauge")), - Some(config.getFiniteDuration("gauge.refresh-interval")) - ) - - DefaultInstrumentSettings(histogramSettings, minMaxCounterSettings, gaugeSettings) - } -}
\ No newline at end of file |