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

Support user-defined thread or dispatcher name #3231

Closed
mogud opened this issue Apr 1, 2022 · 8 comments
Closed

Support user-defined thread or dispatcher name #3231

mogud opened this issue Apr 1, 2022 · 8 comments
Assignees

Comments

@mogud
Copy link

mogud commented Apr 1, 2022

Thread names in logs output by modules that use coroutines are not consistent with other modules.

@qwwdfsad
Copy link
Contributor

qwwdfsad commented Apr 1, 2022

Could you please elaborate on what exactly do you mean? You can use Executor.asCoroutineDispatcher and configure the thread factory to set any named you want to the corresponding threads

@mogud
Copy link
Author

mogud commented Apr 6, 2022

First, we use ktor as our network basis, and it also cannot configure dispatcher name or thread name.
On the other hand, Dispatchers.Default is exactly what we want except the name. So it may be a little bit over control to create a new Executor only for the name issue.

@qwwdfsad
Copy link
Contributor

qwwdfsad commented Apr 6, 2022

Could you please elaborate on for what purpose do you need a configurable Dispatchers.Default name?

@mogud
Copy link
Author

mogud commented Apr 7, 2022

For consistency.

In our case, we use some standalone threads to process particular light tasks, like commands. It's convenient to filter logs for other purposes if normalized thread names are contained in final ouput. However, dispatchers' names are not consistent with our log conventions. So, we have to customize our logger tool to support something like markers and mark everywhere.

It doesn't mean that it's hard to deal with this case. We can use some builders to make codes not too verbose. But as CORE_POOL_SIZE and MAX_POOL_SIZE already can be configured, maybe to support configure DEFAULT_SCHEDULER_NAME is reasonable enough. Although formating support is better.

@qwwdfsad
Copy link
Contributor

qwwdfsad commented Apr 7, 2022

Thanks for the explanation and also a reminder about scheduler configurability via system props! The system property is indeed can be a way to go here

@dovchinnikov
Copy link
Contributor

This was also requested in IJ team

@IgnatBeresnev
Copy link
Member

As proposed, customization through kotlinx.coroutines.scheduler.default.name system property has been implemented in #3465

@dkhalanskyjb
Copy link
Collaborator

(to be closed automatically when the changes enter master)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants