Skip to content
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

remove the start method from the Module interface #588

Merged
merged 1 commit into from
May 29, 2019

Conversation

ivantopo
Copy link
Contributor

While creating and updating modules I noticed one small annoyance that is sort of forced by the Module interface: since users are supposed to implement a start method but obviously there are always a number of "things" that need to be instantiated for the module to work then we end up creating modules with a bunch of vars that are initialized with some sort of default value or defined as Option[X] and then create the actual values when start is called, but, in practice, there is no need to do that. All modules are instantiated right when they are going to be started, there is no chance to have an instantiated but not started module so I'm proposing to remove the start method from the Module interface.

Besides that change, I'm adding a ModuleFactory to be used when the modules are automatically instantiated by Kamon instead of provided by the user (which will be the default behavior).. this way, we force the parameter-less constructor only on the Factory and the Module itself is free to receive/grab any dependencies it might need on its constructor.

val executor = Executors.newSingleThreadExecutor(threadFactory(settings.name))
Entry(settings.name, ExecutionContext.fromExecutorService(executor), programmaticallyAdded, settings, instance)

// Scheduling any task on the executor ensures that the underlying Thread is created and that the JVM will stay
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this desired? Couldn't this cause the JVM to hang on exit if there is an issue? I think that could be extremely confusing fo rusers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to force people to shutdown the modules so that they have a final chance to report any accumulated data, we even have some tests covering this behavior and #533 that are sort of related to this.

If an user sees that while testing their JVM doesn't shutdown then their are much more likely to take this into account and properly call Kamon.stopModules() before shutting down the app.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be probably documented somewhere. We've just came into this issue of hanging application because of Kamon modules. I'd expect somewhere in installation guide that user should handle stopping of modules.

@dpsoft
Copy link
Contributor

dpsoft commented May 28, 2019

@ivantopo LGTM!

@ivantopo ivantopo merged commit 279750e into kamon-io:master May 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants