aboutsummaryrefslogtreecommitdiff
path: root/kamon-core/src/main/scala/kamon/ReporterRegistry.scala
diff options
context:
space:
mode:
authorIvan Topolnjak <ivantopo@gmail.com>2017-06-08 16:05:32 +0200
committerIvan Topolnjak <ivantopo@gmail.com>2017-06-08 16:05:32 +0200
commitb2b43016b2b652ebcd686959048e3c5fe427e649 (patch)
tree6d65890e0d808ac7b6c2e0e98843a4a0a4c972cb /kamon-core/src/main/scala/kamon/ReporterRegistry.scala
parentb94ca0cbb931799ccd2ad2d245660c4d48032c83 (diff)
downloadKamon-b2b43016b2b652ebcd686959048e3c5fe427e649.tar.gz
Kamon-b2b43016b2b652ebcd686959048e3c5fe427e649.tar.bz2
Kamon-b2b43016b2b652ebcd686959048e3c5fe427e649.zip
expose all apis through the Kamon companion object
Diffstat (limited to 'kamon-core/src/main/scala/kamon/ReporterRegistry.scala')
-rw-r--r--kamon-core/src/main/scala/kamon/ReporterRegistry.scala55
1 files changed, 31 insertions, 24 deletions
diff --git a/kamon-core/src/main/scala/kamon/ReporterRegistry.scala b/kamon-core/src/main/scala/kamon/ReporterRegistry.scala
index 45c93ec4..4e661676 100644
--- a/kamon-core/src/main/scala/kamon/ReporterRegistry.scala
+++ b/kamon-core/src/main/scala/kamon/ReporterRegistry.scala
@@ -15,14 +15,14 @@ import scala.collection.JavaConverters._
import scala.collection.concurrent.TrieMap
trait ReporterRegistry {
- def loadFromConfig(): Unit
+ def loadReportersFromConfig(): Unit
- def add(reporter: MetricReporter): Registration
- def add(reporter: MetricReporter, name: String): Registration
- def add(reporter: SpanReporter): Registration
- def add(reporter: SpanReporter, name: String): Registration
+ def addReporter(reporter: MetricReporter): Registration
+ def addReporter(reporter: MetricReporter, name: String): Registration
+ def addReporter(reporter: SpanReporter): Registration
+ def addReporter(reporter: SpanReporter, name: String): Registration
- def stopAll(): Future[Unit]
+ def stopAllReporters(): Future[Unit]
}
@@ -47,29 +47,31 @@ trait SpanReporter {
}
class ReporterRegistryImpl(metrics: MetricsSnapshotGenerator, initialConfig: Config) extends ReporterRegistry {
+ private val registryExecutionContext = Executors.newScheduledThreadPool(2, threadFactory("kamon-reporter-registry"))
private val reporterCounter = new AtomicLong(0L)
- private val registryExecutionContext = Executors.newSingleThreadScheduledExecutor(threadFactory("kamon-reporter-registry"))
- private val metricsTickerSchedule = new AtomicReference[ScheduledFuture[_]]()
- private val spanReporterTickerSchedule = new AtomicReference[ScheduledFuture[_]]()
+ private val metricReporterTickerSchedule = new AtomicReference[ScheduledFuture[_]]()
private val metricReporters = TrieMap[Long, MetricReporterEntry]()
+
+ private val spanReporterTickerSchedule = new AtomicReference[ScheduledFuture[_]]()
private val spanReporters = TrieMap[Long, SpanReporterEntry]()
+
reconfigure(initialConfig)
- override def loadFromConfig(): Unit = ???
+ override def loadReportersFromConfig(): Unit = ???
- override def add(reporter: MetricReporter): Registration =
+ override def addReporter(reporter: MetricReporter): Registration =
addMetricReporter(reporter, reporter.getClass.getName())
- override def add(reporter: MetricReporter, name: String): Registration =
+ override def addReporter(reporter: MetricReporter, name: String): Registration =
addMetricReporter(reporter, name)
- override def add(reporter: SpanReporter): Registration =
+ override def addReporter(reporter: SpanReporter): Registration =
addSpanReporter(reporter, reporter.getClass.getName())
- override def add(reporter: SpanReporter, name: String): Registration =
+ override def addReporter(reporter: SpanReporter, name: String): Registration =
addSpanReporter(reporter, name)
@@ -103,7 +105,7 @@ class ReporterRegistryImpl(metrics: MetricsSnapshotGenerator, initialConfig: Con
metricReporters.remove(id).nonEmpty
}
- override def stopAll(): Future[Unit] = {
+ override def stopAllReporters(): Future[Unit] = {
implicit val stopReporterExeContext = ExecutionContext.fromExecutor(registryExecutionContext)
val reporterStopFutures = Vector.newBuilder[Future[Unit]]
@@ -128,9 +130,14 @@ class ReporterRegistryImpl(metrics: MetricsSnapshotGenerator, initialConfig: Con
val tickIntervalMillis = config.getDuration("kamon.metric.tick-interval", TimeUnit.MILLISECONDS)
val traceTickIntervalMillis = config.getDuration("kamon.trace.tick-interval", TimeUnit.MILLISECONDS)
- val currentTicker = metricsTickerSchedule.get()
- if(currentTicker != null) {
- currentTicker.cancel(true)
+ val currentMetricTicker = metricReporterTickerSchedule.get()
+ if(currentMetricTicker != null) {
+ currentMetricTicker.cancel(true)
+ }
+
+ val currentSpanTicker = spanReporterTickerSchedule.get()
+ if(currentSpanTicker != null) {
+ currentSpanTicker .cancel(true)
}
// Reconfigure all registered reporters
@@ -142,15 +149,15 @@ class ReporterRegistryImpl(metrics: MetricsSnapshotGenerator, initialConfig: Con
Future(entry.reporter.reconfigure(config))(entry.executionContext)
}
- metricsTickerSchedule.set {
+ metricReporterTickerSchedule.set {
registryExecutionContext.scheduleAtFixedRate(
- new MetricTicker(metrics, metricReporters), tickIntervalMillis, tickIntervalMillis, TimeUnit.MILLISECONDS
+ new MetricReporterTicker(metrics, metricReporters), tickIntervalMillis, tickIntervalMillis, TimeUnit.MILLISECONDS
)
}
spanReporterTickerSchedule.set {
registryExecutionContext.scheduleAtFixedRate(
- new SpanTicker(spanReporters), traceTickIntervalMillis, traceTickIntervalMillis, TimeUnit.MILLISECONDS
+ new SpanReporterTicker(spanReporters), traceTickIntervalMillis, traceTickIntervalMillis, TimeUnit.MILLISECONDS
)
}
}
@@ -195,8 +202,8 @@ class ReporterRegistryImpl(metrics: MetricsSnapshotGenerator, initialConfig: Con
val buffer = new ArrayBlockingQueue[Span.CompletedSpan](bufferCapacity)
}
- private class MetricTicker(snapshotGenerator: MetricsSnapshotGenerator, reporterEntries: TrieMap[Long, MetricReporterEntry]) extends Runnable {
- val logger = Logger(classOf[MetricTicker])
+ private class MetricReporterTicker(snapshotGenerator: MetricsSnapshotGenerator, reporterEntries: TrieMap[Long, MetricReporterEntry]) extends Runnable {
+ val logger = Logger(classOf[MetricReporterTicker])
var lastTick = System.currentTimeMillis()
def run(): Unit = try {
@@ -221,7 +228,7 @@ class ReporterRegistryImpl(metrics: MetricsSnapshotGenerator, initialConfig: Con
}
}
- private class SpanTicker(spanReporters: TrieMap[Long, SpanReporterEntry]) extends Runnable {
+ private class SpanReporterTicker(spanReporters: TrieMap[Long, SpanReporterEntry]) extends Runnable {
override def run(): Unit = {
spanReporters.foreach {
case (_, entry) =>