diff options
author | Ivan Topolnak <itopolnak@despegar.com> | 2014-03-07 18:08:01 -0300 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2014-03-11 21:14:53 -0300 |
commit | b6af84ab6b60b4ca6c0389c8c3622db3d3c27915 (patch) | |
tree | 1f89896820e36d59daadef7699b434de1051be42 /kamon-core/src/main/scala/kamon/metrics/package.scala | |
parent | ccbcc55282251b5e6d4f41384730232a8f0e7d05 (diff) | |
download | Kamon-b6af84ab6b60b4ca6c0389c8c3622db3d3c27915.tar.gz Kamon-b6af84ab6b60b4ca6c0389c8c3622db3d3c27915.tar.bz2 Kamon-b6af84ab6b60b4ca6c0389c8c3622db3d3c27915.zip |
multiple fixes to the custom metrics collection facilities
Diffstat (limited to 'kamon-core/src/main/scala/kamon/metrics/package.scala')
-rw-r--r-- | kamon-core/src/main/scala/kamon/metrics/package.scala | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/kamon-core/src/main/scala/kamon/metrics/package.scala b/kamon-core/src/main/scala/kamon/metrics/package.scala index f89d84a3..640157a9 100644 --- a/kamon-core/src/main/scala/kamon/metrics/package.scala +++ b/kamon-core/src/main/scala/kamon/metrics/package.scala @@ -16,11 +16,24 @@ package kamon +import scala.annotation.tailrec +import com.typesafe.config.Config + package object metrics { - def combineMaps[K, V](left: Map[K, V], right: Map[K, V])(valueMerger: (V, V) ⇒ V): Map[K, V] = { - (left ++ right) map { - case (key, rightValue) ⇒ key -> left.get(key).map(leftValue ⇒ valueMerger(leftValue, rightValue)).getOrElse(rightValue) + case class HdrPrecisionConfig(highestTrackableValue: Long, significantValueDigits: Int) + + def extractPrecisionConfig(config: Config): HdrPrecisionConfig = + HdrPrecisionConfig(config.getLong("highest-trackable-value"), config.getInt("significant-value-digits")) + + @tailrec def combineMaps[K, V](left: Map[K, V], right: Map[K, V])(valueMerger: (V, V) ⇒ V): Map[K, V] = { + if (right.isEmpty) + left + else { + val (key, rightValue) = right.head + val value = left.get(key).map(valueMerger(_, rightValue)).getOrElse(rightValue) + + combineMaps(left.updated(key, value), right.tail)(valueMerger) } } } |