-
Notifications
You must be signed in to change notification settings - Fork 49
Add SynchronousNonBlockingStepExecutorServiceAugmentor
#226
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
base: master
Are you sure you want to change the base?
Add SynchronousNonBlockingStepExecutorServiceAugmentor
#226
Conversation
I am not sure I follow the use case, and there is no downstream PR. My general recommendation for any code creating an try { // TODO Java 21+
return (ExecutorService) Executors.class.getMethod("newVirtualThreadPerTaskExecutor").invoke(null);
} catch (NoSuchMethodException x) {
return Executors.newCachedThreadPool(/* as before */);
} catch (Exception x) {
throw new AssertionError(x);
} which should probably be made into an API in Jenkins core. |
Just filed the downstream PR: jenkinsci/opentelemetry-plugin#1139 |
My (limited) understanding of the current state with virtual threads was that unless you are running homogenous tasks that you know do not use |
FTR @jgreffe if you want to update the PR description here is some extra context:
In order for this to work, plugins need access to an OTel
There may be other ways to accomplish the same use case, but we have not explored them at this time:
|
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 added a comment with some context after thinking about possible alternative approaches. I also added some comments upstream about the fact that the new extension point wouldn't work for dynamic plugin installations, but IDK how important that is.
} | ||
return executorService; | ||
} | ||
|
||
/** | ||
* Extension point for augmenting the executorService of {@link SynchronousNonBlockingStepExecution}. |
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.
Might need an import for this, not sure.
* Extension point for augmenting the executorService of {@link SynchronousNonBlockingStepExecution}. | |
* Extension point for augmenting the executorService of {@link SynchronousNonBlockingStepExecution} and {@link GeneralNonBlockingStepExecution}. |
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.
Please see d44f505
* Extension point for augmenting the executorService of {@link SynchronousNonBlockingStepExecution}. | ||
*/ | ||
@Restricted(Beta.class) | ||
public interface SynchronousNonBlockingStepExecutorServiceAugmentor extends ExtensionPoint { |
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.
Given this is an inner class, I would probably just name it ExecutorServiceAugmentor
.
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.
Please see d44f505
Sure, it depends on what the thread is doing. Anyway that is irrelevant to the apparent purpose of this API based on the downstream PR. |
@jglick : then should I apply your suggestion? #226 (comment) |
Looking into a similar case in jenkinsci/opentelemetry-plugin#1137, I also thought about instead adding a dependency on I am a little more hesitant about adding dependencies to this plugin than to |
Allow the
executorService
to be augmented.This avoids having to use reflection by dependent plugins.
Updated with comment from @dwnusbaum
Testing done
Submitter checklist