aboutsummaryrefslogtreecommitdiff
path: root/kamon-core/src/main/scala/kamon/ReporterRegistry.scala
diff options
context:
space:
mode:
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)