diff options
author | Ivan Topolnak <itopolnak@despegar.com> | 2014-02-06 10:23:34 -0300 |
---|---|---|
committer | Ivan Topolnak <itopolnak@despegar.com> | 2014-02-06 10:48:34 -0300 |
commit | 042b5d3c57634598eeca1359a90e7546b0e7c3c5 (patch) | |
tree | d0586e8fd9887c5adc8a666f83b75a259a475228 /kamon-core/src/main/scala/kamon/metrics | |
parent | 1e5deeac75d900635e46705224ad3e3db786d4a8 (diff) | |
download | Kamon-042b5d3c57634598eeca1359a90e7546b0e7c3c5.tar.gz Kamon-042b5d3c57634598eeca1359a90e7546b0e7c3c5.tar.bz2 Kamon-042b5d3c57634598eeca1359a90e7546b0e7c3c5.zip |
minor cleanup before relasing 0.0.13
Diffstat (limited to 'kamon-core/src/main/scala/kamon/metrics')
-rw-r--r-- | kamon-core/src/main/scala/kamon/metrics/Subscriptions.scala | 20 | ||||
-rw-r--r-- | kamon-core/src/main/scala/kamon/metrics/package.scala | 4 |
2 files changed, 11 insertions, 13 deletions
diff --git a/kamon-core/src/main/scala/kamon/metrics/Subscriptions.scala b/kamon-core/src/main/scala/kamon/metrics/Subscriptions.scala index 2111563b..4b022377 100644 --- a/kamon-core/src/main/scala/kamon/metrics/Subscriptions.scala +++ b/kamon-core/src/main/scala/kamon/metrics/Subscriptions.scala @@ -16,10 +16,10 @@ package kamon.metrics -import akka.actor.{Props, ActorRef, Actor} +import akka.actor.{ Props, ActorRef, Actor } import kamon.metrics.Subscriptions.{ MetricGroupFilter, FlushMetrics, TickMetricSnapshot, Subscribe } import kamon.util.GlobPathFilter -import scala.concurrent.duration.{FiniteDuration, Duration} +import scala.concurrent.duration.{ FiniteDuration, Duration } import java.util.concurrent.TimeUnit import kamon.Kamon import kamon.metrics.TickMetricSnapshotBuffer.FlushBuffer @@ -88,38 +88,36 @@ object Subscriptions { } } - class TickMetricSnapshotBuffer(flushInterval: FiniteDuration, receiver: ActorRef) extends Actor { val flushSchedule = context.system.scheduler.schedule(flushInterval, flushInterval, self, FlushBuffer)(context.dispatcher) def receive = empty def empty: Actor.Receive = { - case tick : TickMetricSnapshot => context become(buffering(tick)) - case FlushBuffer => // Nothing to flush. + case tick: TickMetricSnapshot ⇒ context become (buffering(tick)) + case FlushBuffer ⇒ // Nothing to flush. } def buffering(buffered: TickMetricSnapshot): Actor.Receive = { - case TickMetricSnapshot(_, to, tickMetrics) => + case TickMetricSnapshot(_, to, tickMetrics) ⇒ val combinedMetrics = combineMaps(buffered.metrics, tickMetrics)(mergeMetricGroup) val combinedSnapshot = TickMetricSnapshot(buffered.from, to, combinedMetrics) - context become(buffering(combinedSnapshot)) + context become (buffering(combinedSnapshot)) - case FlushBuffer => + case FlushBuffer ⇒ receiver ! buffered - context become(empty) + context become (empty) } - override def postStop(): Unit = { flushSchedule.cancel() super.postStop() } def mergeMetricGroup(left: MetricGroupSnapshot, right: MetricGroupSnapshot) = new MetricGroupSnapshot { - val metrics = combineMaps(left.metrics, right.metrics)((l, r) => l.merge(r)) + val metrics = combineMaps(left.metrics, right.metrics)((l, r) ⇒ l.merge(r)) } } diff --git a/kamon-core/src/main/scala/kamon/metrics/package.scala b/kamon-core/src/main/scala/kamon/metrics/package.scala index 765ebaca..f89d84a3 100644 --- a/kamon-core/src/main/scala/kamon/metrics/package.scala +++ b/kamon-core/src/main/scala/kamon/metrics/package.scala @@ -18,9 +18,9 @@ package kamon package object metrics { - def combineMaps[K, V](left: Map[K, V], right: Map[K, V])(valueMerger: (V, V) => V): Map[K, V] = { + 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 (key, rightValue) ⇒ key -> left.get(key).map(leftValue ⇒ valueMerger(leftValue, rightValue)).getOrElse(rightValue) } } } |