diff options
Diffstat (limited to 'kamon-core/src/main/scala/kamon/metric/RecorderRegistry.scala')
-rw-r--r-- | kamon-core/src/main/scala/kamon/metric/RecorderRegistry.scala | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/kamon-core/src/main/scala/kamon/metric/RecorderRegistry.scala b/kamon-core/src/main/scala/kamon/metric/RecorderRegistry.scala index 53081760..fd728b1d 100644 --- a/kamon-core/src/main/scala/kamon/metric/RecorderRegistry.scala +++ b/kamon-core/src/main/scala/kamon/metric/RecorderRegistry.scala @@ -1,6 +1,7 @@ package kamon package metric +import java.util.concurrent.ScheduledThreadPoolExecutor import java.util.concurrent.atomic.AtomicReference import com.typesafe.config.Config @@ -16,6 +17,7 @@ trait RecorderRegistry { } class RecorderRegistryImpl(initialConfig: Config) extends RecorderRegistry { + private val scheduler = new ScheduledThreadPoolExecutor(1, numberedThreadFactory("kamon.metric.refresh-scheduler")) private val instrumentFactory = new AtomicReference[InstrumentFactory]() private val entityFilter = new AtomicReference[EntityFilter]() private val entities = TrieMap.empty[Entity, EntityRecorder with EntitySnapshotProducer] @@ -27,7 +29,7 @@ class RecorderRegistryImpl(initialConfig: Config) extends RecorderRegistry { entityFilter.get().accept(entity) override def getRecorder(entity: Entity): EntityRecorder = - entities.atomicGetOrElseUpdate(entity, new DefaultEntityRecorder(entity, instrumentFactory.get())) + entities.atomicGetOrElseUpdate(entity, new DefaultEntityRecorder(entity, instrumentFactory.get(), scheduler)) override def removeRecorder(entity: Entity): Boolean = entities.remove(entity).nonEmpty @@ -35,13 +37,20 @@ class RecorderRegistryImpl(initialConfig: Config) extends RecorderRegistry { private[kamon] def reconfigure(config: Config): Unit = synchronized { instrumentFactory.set(InstrumentFactory.fromConfig(config)) entityFilter.set(EntityFilter.fromConfig(config)) + + val refreshSchedulerPoolSize = config.getInt("kamon.metric.refresh-scheduler-pool-size") + scheduler.setCorePoolSize(refreshSchedulerPoolSize) } private[kamon] def snapshot(): Seq[EntitySnapshot] = { entities.values.map(_.snapshot()).toSeq } + + //private[kamon] def diagnosticData } +case class RecorderRegistryDiagnostic(entities: Seq[Entity]) + |