-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Kamon.stop method #804
Conversation
core/kamon-core/src/main/scala/kamon/module/ModuleRegistry.scala
Outdated
Show resolved
Hide resolved
65de6b3
to
08cde9c
Compare
import com.typesafe.config.{Config, ConfigUtil} | ||
|
||
import scala.collection.concurrent.TrieMap | ||
|
||
package object kamon { | ||
|
||
def newScheduledThreadPool(corePoolSize: Int, threadFactory: ThreadFactory): ScheduledExecutorService = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ivantopo this will make the threads stop if there is no more work in the queues. I got this from https://github.com/typelevel/cats-effect/blob/series/2.x/core/jvm/src/main/scala/cats/effect/internals/IOTimer.scala#L72-L98.
Do you think we should make this configurable instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't make it configurable unless there was an effect to end users. For now, leave it as it is.
@@ -39,8 +39,9 @@ import scala.util.control.NonFatal | |||
class ModuleRegistry(configuration: Configuration, clock: Clock, metricRegistry: MetricRegistry, tracer: Tracer) { | |||
|
|||
private val _logger = LoggerFactory.getLogger(classOf[ModuleRegistry]) | |||
private val _metricsTickerExecutor = Executors.newScheduledThreadPool(1, threadFactory("kamon-metrics-ticker", daemon = true)) | |||
private val _spansTickerExecutor = Executors.newScheduledThreadPool(1, threadFactory("kamon-spans-ticker", daemon = true)) | |||
private val _moduleRegistryEC: ExecutionContext = ExecutionContext.fromExecutor(newScheduledThreadPool(1, threadFactory("kamon-module-registry", daemon = true))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
introduced another EC to be used by shutdown logic...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it is fine :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work @jtjeferreira! We are finally be leak-free in Play development mode 🎉
@@ -39,8 +39,9 @@ import scala.util.control.NonFatal | |||
class ModuleRegistry(configuration: Configuration, clock: Clock, metricRegistry: MetricRegistry, tracer: Tracer) { | |||
|
|||
private val _logger = LoggerFactory.getLogger(classOf[ModuleRegistry]) | |||
private val _metricsTickerExecutor = Executors.newScheduledThreadPool(1, threadFactory("kamon-metrics-ticker", daemon = true)) | |||
private val _spansTickerExecutor = Executors.newScheduledThreadPool(1, threadFactory("kamon-spans-ticker", daemon = true)) | |||
private val _moduleRegistryEC: ExecutionContext = ExecutionContext.fromExecutor(newScheduledThreadPool(1, threadFactory("kamon-module-registry", daemon = true))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it is fine :D
import com.typesafe.config.{Config, ConfigUtil} | ||
|
||
import scala.collection.concurrent.TrieMap | ||
|
||
package object kamon { | ||
|
||
def newScheduledThreadPool(corePoolSize: Int, threadFactory: ThreadFactory): ScheduledExecutorService = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't make it configurable unless there was an effect to end users. For now, leave it as it is.
A different approach to #780