diff options
Diffstat (limited to 'kamon-core/src/main/scala/kamon')
-rw-r--r-- | kamon-core/src/main/scala/kamon/Kamon.scala | 2 | ||||
-rw-r--r-- | kamon-core/src/main/scala/kamon/ReporterRegistry.scala | 2 | ||||
-rw-r--r-- | kamon-core/src/main/scala/kamon/package.scala | 6 |
3 files changed, 6 insertions, 4 deletions
diff --git a/kamon-core/src/main/scala/kamon/Kamon.scala b/kamon-core/src/main/scala/kamon/Kamon.scala index 562ef615..8f69ab41 100644 --- a/kamon-core/src/main/scala/kamon/Kamon.scala +++ b/kamon-core/src/main/scala/kamon/Kamon.scala @@ -37,7 +37,7 @@ object Kamon extends MetricLookup with ReporterRegistry with Tracer { @volatile private var _filters = Filters.fromConfig(_config) private val _clock = new Clock.Default() - private val _scheduler = Executors.newScheduledThreadPool(schedulerPoolSize(_config), numberedThreadFactory("kamon-scheduler")) + private val _scheduler = Executors.newScheduledThreadPool(schedulerPoolSize(_config), numberedThreadFactory("kamon-scheduler", daemon = true)) private val _metrics = new MetricRegistry(_config, _scheduler) private val _reporterRegistry = new ReporterRegistry.Default(_metrics, _config, _clock) private val _tracer = Tracer.Default(Kamon, _reporterRegistry, _config, _clock) diff --git a/kamon-core/src/main/scala/kamon/ReporterRegistry.scala b/kamon-core/src/main/scala/kamon/ReporterRegistry.scala index 213ad19f..ee70de4a 100644 --- a/kamon-core/src/main/scala/kamon/ReporterRegistry.scala +++ b/kamon-core/src/main/scala/kamon/ReporterRegistry.scala @@ -67,7 +67,7 @@ object ReporterRegistry { private[kamon] class Default(metrics: MetricsSnapshotGenerator, initialConfig: Config, clock: Clock) extends ReporterRegistry with SpanSink { private val logger = LoggerFactory.getLogger(classOf[ReporterRegistry]) - private val registryExecutionContext = Executors.newScheduledThreadPool(2, threadFactory("kamon-reporter-registry")) + private val registryExecutionContext = Executors.newScheduledThreadPool(2, threadFactory("kamon-reporter-registry", daemon = true)) private val reporterCounter = new AtomicLong(0L) private var registryConfiguration = readRegistryConfiguration(initialConfig) diff --git a/kamon-core/src/main/scala/kamon/package.scala b/kamon-core/src/main/scala/kamon/package.scala index c746efa1..d3b25500 100644 --- a/kamon-core/src/main/scala/kamon/package.scala +++ b/kamon-core/src/main/scala/kamon/package.scala @@ -30,18 +30,19 @@ package object kamon { /** * Creates a thread factory that assigns the specified name to all created Threads. */ - def threadFactory(name: String): ThreadFactory = + def threadFactory(name: String, daemon: Boolean = false): ThreadFactory = new ThreadFactory { val defaultFactory = Executors.defaultThreadFactory() override def newThread(r: Runnable): Thread = { val thread = defaultFactory.newThread(r) thread.setName(name) + thread.setDaemon(daemon) thread } } - def numberedThreadFactory(name: String): ThreadFactory = + def numberedThreadFactory(name: String, daemon: Boolean = false): ThreadFactory = new ThreadFactory { val count = new AtomicLong() val defaultFactory = Executors.defaultThreadFactory() @@ -49,6 +50,7 @@ package object kamon { override def newThread(r: Runnable): Thread = { val thread = defaultFactory.newThread(r) thread.setName(name + "-" + count.incrementAndGet().toString) + thread.setDaemon(daemon) thread } } |