diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2014-07-04 01:51:58 -0300 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2014-07-04 01:51:58 -0300 |
commit | ac2367c8e80bbe6a76f36bd42de9aa9848b0e87b (patch) | |
tree | 15c333bf98222fee71d120585733b963f31ae616 /kamon-core/src/main/scala/kamon/metric/Subscriptions.scala | |
parent | 8d46b83a5b1c45cf292f3d4d9af362c2c75fd2dc (diff) | |
download | Kamon-ac2367c8e80bbe6a76f36bd42de9aa9848b0e87b.tar.gz Kamon-ac2367c8e80bbe6a76f36bd42de9aa9848b0e87b.tar.bz2 Kamon-ac2367c8e80bbe6a76f36bd42de9aa9848b0e87b.zip |
+ core: introduce the new kamon.metrics.default-collection-context-buffer-size setting
Diffstat (limited to 'kamon-core/src/main/scala/kamon/metric/Subscriptions.scala')
-rw-r--r-- | kamon-core/src/main/scala/kamon/metric/Subscriptions.scala | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/kamon-core/src/main/scala/kamon/metric/Subscriptions.scala b/kamon-core/src/main/scala/kamon/metric/Subscriptions.scala index a9f4c721..eb2168ad 100644 --- a/kamon-core/src/main/scala/kamon/metric/Subscriptions.scala +++ b/kamon-core/src/main/scala/kamon/metric/Subscriptions.scala @@ -30,6 +30,7 @@ class Subscriptions extends Actor { val config = context.system.settings.config val tickInterval = Duration(config.getDuration("kamon.metrics.tick-interval", TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS) val flushMetricsSchedule = context.system.scheduler.schedule(tickInterval, tickInterval, self, FlushMetrics)(context.dispatcher) + val collectionContext = Kamon(Metrics).buildDefaultCollectionContext var lastTick: Long = System.currentTimeMillis() var subscribedPermanently: Map[MetricGroupFilter, List[ActorRef]] = Map.empty @@ -55,7 +56,7 @@ class Subscriptions extends Actor { def flush(): Unit = { val currentTick = System.currentTimeMillis() - val snapshots = Kamon(Metrics).collect + val snapshots = collectAll() dispatchSelectedMetrics(lastTick, currentTick, subscribedPermanently, snapshots) dispatchSelectedMetrics(lastTick, currentTick, subscribedForOneShot, snapshots) @@ -64,6 +65,9 @@ class Subscriptions extends Actor { subscribedForOneShot = Map.empty } + def collectAll(): Map[MetricGroupIdentity, MetricGroupSnapshot] = + (for ((identity, recorder) ← Kamon(Metrics).storage) yield (identity, recorder.collect(collectionContext))).toMap + def dispatchSelectedMetrics(lastTick: Long, currentTick: Long, subscriptions: Map[MetricGroupFilter, List[ActorRef]], snapshots: Map[MetricGroupIdentity, MetricGroupSnapshot]): Unit = { @@ -90,7 +94,7 @@ object Subscriptions { class TickMetricSnapshotBuffer(flushInterval: FiniteDuration, receiver: ActorRef) extends Actor { val flushSchedule = context.system.scheduler.schedule(flushInterval, flushInterval, self, FlushBuffer)(context.dispatcher) - val collectionContext = CollectionContext.default + val collectionContext = Kamon(Metrics)(context.system).buildDefaultCollectionContext def receive = empty |