-
Notifications
You must be signed in to change notification settings - Fork 70
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 Embedded mode #262
Add Embedded mode #262
Conversation
recoveryProcessor = new TaskProcessor(recoveryThreadPool, appConfig.getReporter()); | ||
|
||
collectionProcessor = new TaskProcessor(collectionThreadPool, appConfig.getReporter()); |
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.
instead of an embedded setting, perhaps it would be better to take an ExecutorService as an option?
What is the impact if it doesn't have these threadpools?
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 am not sure to follow your point here.
In embedded mode, collectionThreadPool & recoveryThreadPool variables are null, so TaskProcessor instances don't have any ExecutorService.
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.
Then what thread is jmxfetch even running on?
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.
The calling thread, i.e. the thread calling App.run()
method.
In case of the tracer, this is the dd-jmx-collector
thread created by the tracer.
see: https://github.com/DataDog/dd-trace-java/blob/master/dd-java-agent/agent-jmxfetch/src/main/java/datadog/trace/agent/jmxfetch/JMXFetch.java#L90
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.
This looks very sensible to me and follows the discussion we had to the T. Running the collection, recovery tasks on the main thread (which shouldn't really be an issue ever really) on embedded mode is probably acceptable in any case. I will do some thinking to see if I can come up with any dangerous use-case.
Great stuff, thank you.
@@ -155,4 +145,32 @@ public TaskStatusHandler invoke(Instance instance, Future<Boolean> future, Repor | |||
} | |||
} | |||
} | |||
|
|||
@Test | |||
public void embeddedTaskProcessor() throws Throwable { |
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.
🍰
When JMXFetch is embedded into the client app through tracer agent for example, we want to have a special mode to avoid creating thread pools that are only used for dealing with JMX remote connections TaskProcessor is taking care of the case where there is no ThreadPoolExecutor and calling tasks by the calling thread
e51cfa6
to
967c771
Compare
When JMXFetch is embedded into the client app through tracer agent for example, we want to have a special mode
to avoid creating thread pools that are only used for dealing with JMX remote connections
TaskProcessor is taking care of the case where there is no ThreadPoolExecutor and calling tasks by the calling thread