aboutsummaryrefslogtreecommitdiff
path: root/kamon-core/src/main/scala/kamon/ReporterRegistry.scala
diff options
context:
space:
mode:
authorIvan Topolnjak <ivantopo@gmail.com>2017-06-11 10:02:22 +0200
committerIvan Topolnjak <ivantopo@gmail.com>2017-06-11 10:02:22 +0200
commite8d3e612dcf0fa396a25920a23f108f6ab8c2e61 (patch)
treee1d702aa2eabbfabc9690a5cdc3ca6ac59ae69b9 /kamon-core/src/main/scala/kamon/ReporterRegistry.scala
parentde3e823cec6ec12d551f568b73d2ad1061944222 (diff)
downloadKamon-e8d3e612dcf0fa396a25920a23f108f6ab8c2e61.tar.gz
Kamon-e8d3e612dcf0fa396a25920a23f108f6ab8c2e61.tar.bz2
Kamon-e8d3e612dcf0fa396a25920a23f108f6ab8c2e61.zip
separate metrics from instruments and add default instrument for metrics
Diffstat (limited to 'kamon-core/src/main/scala/kamon/ReporterRegistry.scala')
-rw-r--r--kamon-core/src/main/scala/kamon/ReporterRegistry.scala15
1 files changed, 8 insertions, 7 deletions
diff --git a/kamon-core/src/main/scala/kamon/ReporterRegistry.scala b/kamon-core/src/main/scala/kamon/ReporterRegistry.scala
index 7ef9047d..27a4a6ea 100644
--- a/kamon-core/src/main/scala/kamon/ReporterRegistry.scala
+++ b/kamon-core/src/main/scala/kamon/ReporterRegistry.scala
@@ -65,12 +65,11 @@ class ReporterRegistryImpl(metrics: MetricsSnapshotGenerator, initialConfig: Con
private val registryExecutionContext = Executors.newScheduledThreadPool(2, threadFactory("kamon-reporter-registry"))
private val reporterCounter = new AtomicLong(0L)
- private val metricReporterTickerSchedule = new AtomicReference[ScheduledFuture[_]]()
private val metricReporters = TrieMap[Long, MetricReporterEntry]()
+ private val metricReporterTickerSchedule = new AtomicReference[ScheduledFuture[_]]()
- private val spanReporterTickerSchedule = new AtomicReference[ScheduledFuture[_]]()
private val spanReporters = TrieMap[Long, SpanReporterEntry]()
-
+ private val spanReporterTickerSchedule = new AtomicReference[ScheduledFuture[_]]()
reconfigure(initialConfig)
@@ -90,7 +89,7 @@ class ReporterRegistryImpl(metrics: MetricsSnapshotGenerator, initialConfig: Con
addSpanReporter(reporter, name)
- private def addMetricReporter(reporter: MetricReporter, name: String): Registration = {
+ private def addMetricReporter(reporter: MetricReporter, name: String): Registration = synchronized {
val executor = Executors.newSingleThreadExecutor(threadFactory(name))
val reporterEntry = new MetricReporterEntry(
id = reporterCounter.getAndIncrement(),
@@ -102,7 +101,7 @@ class ReporterRegistryImpl(metrics: MetricsSnapshotGenerator, initialConfig: Con
createRegistration(reporterEntry.id, metricReporters)
}
- private def addSpanReporter(reporter: SpanReporter, name: String): Registration = {
+ private def addSpanReporter(reporter: SpanReporter, name: String): Registration = synchronized {
val executor = Executors.newSingleThreadExecutor(threadFactory(name))
val reporterEntry = new SpanReporterEntry(
id = reporterCounter.incrementAndGet(),
@@ -117,7 +116,7 @@ class ReporterRegistryImpl(metrics: MetricsSnapshotGenerator, initialConfig: Con
private def createRegistration(id: Long, target: TrieMap[Long, _]): Registration = new Registration {
override def cancel(): Boolean =
- metricReporters.remove(id).nonEmpty
+ target.remove(id).nonEmpty
}
override def stopAllReporters(): Future[Unit] = {
@@ -152,7 +151,7 @@ class ReporterRegistryImpl(metrics: MetricsSnapshotGenerator, initialConfig: Con
val currentSpanTicker = spanReporterTickerSchedule.get()
if(currentSpanTicker != null) {
- currentSpanTicker .cancel(true)
+ currentSpanTicker.cancel(true)
}
// Reconfigure all registered reporters
@@ -177,6 +176,8 @@ class ReporterRegistryImpl(metrics: MetricsSnapshotGenerator, initialConfig: Con
}
}
+
+
private[kamon] def reportSpan(span: Span.CompletedSpan): Unit = {
spanReporters.foreach { case (_, reporterEntry) =>
if(reporterEntry.isActive)