aboutsummaryrefslogtreecommitdiff
path: root/kamon-core/src/main/scala/kamon/metric/RecorderRegistry.scala
diff options
context:
space:
mode:
authorIvan Topolnjak <ivantopo@gmail.com>2017-05-02 13:18:26 +0200
committerIvan Topolnjak <ivantopo@gmail.com>2017-05-02 13:18:26 +0200
commit4247aa319ac6e17b7ef7a76d61bac32c872575e3 (patch)
tree9f16b2c31c272cee658ab9f0b9906e3f4633951e /kamon-core/src/main/scala/kamon/metric/RecorderRegistry.scala
parentf24c1a7a4b96dcfb2609c6f512f34dd6d54de439 (diff)
downloadKamon-4247aa319ac6e17b7ef7a76d61bac32c872575e3.tar.gz
Kamon-4247aa319ac6e17b7ef7a76d61bac32c872575e3.tar.bz2
Kamon-4247aa319ac6e17b7ef7a76d61bac32c872575e3.zip
wip: playing with akka-less implementation of subscriptions
Diffstat (limited to 'kamon-core/src/main/scala/kamon/metric/RecorderRegistry.scala')
-rw-r--r--kamon-core/src/main/scala/kamon/metric/RecorderRegistry.scala44
1 files changed, 44 insertions, 0 deletions
diff --git a/kamon-core/src/main/scala/kamon/metric/RecorderRegistry.scala b/kamon-core/src/main/scala/kamon/metric/RecorderRegistry.scala
new file mode 100644
index 00000000..99974032
--- /dev/null
+++ b/kamon-core/src/main/scala/kamon/metric/RecorderRegistry.scala
@@ -0,0 +1,44 @@
+package kamon
+package metric
+
+import com.typesafe.config.Config
+import kamon.metric.instrument.InstrumentFactory
+
+import scala.collection.concurrent.TrieMap
+
+
+trait RecorderRegistry {
+ def getRecorder(entity: Entity): EntityRecorder
+ def getRecorder(name: String, category: String, tags: Map[String, String]): EntityRecorder
+
+ def removeRecorder(entity: Entity): Boolean
+ 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"))
+ private val entities = TrieMap.empty[Entity, EntityRecorder with EntitySnapshotProducer]
+
+ override def getRecorder(entity: Entity): EntityRecorder = {
+ entities.atomicGetOrElseUpdate(entity, new DefaultEntityRecorder(entity, instrumentFactory))
+ }
+
+ override def getRecorder(name: String, category: String, tags: Map[String, String]): EntityRecorder = ???
+
+ override def removeRecorder(entity: Entity): Boolean = ???
+
+ override def removeRecorder(name: String, category: String, tags: Map[String, String]): Boolean = ???
+
+ private[kamon] def snapshot(): Seq[EntitySnapshot] = {
+ entities.values.map(_.snapshot()).toSeq
+ }
+}
+
+
+
+
+
+
+
+
+