aboutsummaryrefslogtreecommitdiff
path: root/kamon-core/src/main/scala/kamon/metric
diff options
context:
space:
mode:
authorIvan Topolnjak <ivantopo@gmail.com>2017-05-03 12:11:47 +0200
committerIvan Topolnjak <ivantopo@gmail.com>2017-05-03 12:11:47 +0200
commit5dee54a0794b282e9b5729a3d4b85478c12a68d1 (patch)
tree078513a1cddcb66990a11427b2ebdcb2da46f87b /kamon-core/src/main/scala/kamon/metric
parent4247aa319ac6e17b7ef7a76d61bac32c872575e3 (diff)
downloadKamon-5dee54a0794b282e9b5729a3d4b85478c12a68d1.tar.gz
Kamon-5dee54a0794b282e9b5729a3d4b85478c12a68d1.tar.bz2
Kamon-5dee54a0794b282e9b5729a3d4b85478c12a68d1.zip
handle reporters shutdown and reconfigures
Diffstat (limited to 'kamon-core/src/main/scala/kamon/metric')
-rw-r--r--kamon-core/src/main/scala/kamon/metric/RecorderRegistry.scala14
1 files changed, 11 insertions, 3 deletions
diff --git a/kamon-core/src/main/scala/kamon/metric/RecorderRegistry.scala b/kamon-core/src/main/scala/kamon/metric/RecorderRegistry.scala
index 99974032..8b84ab6a 100644
--- a/kamon-core/src/main/scala/kamon/metric/RecorderRegistry.scala
+++ b/kamon-core/src/main/scala/kamon/metric/RecorderRegistry.scala
@@ -1,6 +1,8 @@
package kamon
package metric
+import java.util.concurrent.atomic.AtomicReference
+
import com.typesafe.config.Config
import kamon.metric.instrument.InstrumentFactory
@@ -15,12 +17,14 @@ trait RecorderRegistry {
def removeRecorder(name: String, category: String, tags: Map[String, String]): Boolean
}
-class RecorderRegistryImpl(config: Config) extends RecorderRegistry {
- private val instrumentFactory = InstrumentFactory(config.getConfig("kamon.metric.instrument-factory"))
+class RecorderRegistryImpl(initialConfig: Config) extends RecorderRegistry {
+ private val instrumentFactory = new AtomicReference[InstrumentFactory]()
private val entities = TrieMap.empty[Entity, EntityRecorder with EntitySnapshotProducer]
+ reconfigure(initialConfig)
+
override def getRecorder(entity: Entity): EntityRecorder = {
- entities.atomicGetOrElseUpdate(entity, new DefaultEntityRecorder(entity, instrumentFactory))
+ entities.atomicGetOrElseUpdate(entity, new DefaultEntityRecorder(entity, instrumentFactory.get()))
}
override def getRecorder(name: String, category: String, tags: Map[String, String]): EntityRecorder = ???
@@ -29,6 +33,10 @@ class RecorderRegistryImpl(config: Config) extends RecorderRegistry {
override def removeRecorder(name: String, category: String, tags: Map[String, String]): Boolean = ???
+ private[kamon] def reconfigure(config: Config): Unit = {
+ instrumentFactory.set(InstrumentFactory(config.getConfig("kamon.metric.instrument-factory")))
+ }
+
private[kamon] def snapshot(): Seq[EntitySnapshot] = {
entities.values.map(_.snapshot()).toSeq
}