Skip to content

Commit

Permalink
Ensure scheduler startup in Play applications
Browse files Browse the repository at this point in the history
  • Loading branch information
ivantopo committed Oct 26, 2021
1 parent 103c05f commit 24cf280
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
20 changes: 19 additions & 1 deletion core/kamon-core/src/main/scala/kamon/Init.scala
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,25 @@ trait Init { self: ModuleManagement with Configuration with CurrentStatus with M
self.moduleRegistry().init()

}


/**
* Initializes Kamon without trying to attach the instrumentation agent from the Kamon Bundle.
*/
def initWithoutAttaching(): Unit = {
self.initScheduler()
self.loadModules()
self.moduleRegistry().init()
}

/**
* Initializes Kamon without trying to attach the instrumentation agent from the Kamon Bundle.
*/
def initWithoutAttaching(config: Config): Unit = {
self.reconfigure(config)
self.initWithoutAttaching()
}


def stop(): Future[Unit] = {
self.clearRegistry()
self.stopScheduler()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ object GuiceModule {
Logger(classOf[KamonLoader]).info("Reconfiguring Kamon with Play's Config")
Logger(classOf[KamonLoader]).info(configuration.underlying.getString("play.server.provider"))
Logger(classOf[KamonLoader]).info(configuration.underlying.getString("kamon.trace.tick-interval"))
Kamon.reconfigure(configuration.underlying)
Kamon.loadModules()
Kamon.initWithoutAttaching(configuration.underlying)

lifecycle.addStopHook { () =>
Logger(classOf[KamonLoader]).info("Stopping Kamon")
Expand Down

0 comments on commit 24cf280

Please sign in to comment.