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

Add Embedded mode #262

Merged
merged 1 commit into from
Feb 12, 2020
Merged

Conversation

jpbempel
Copy link
Member

@jpbempel jpbempel commented Feb 5, 2020

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

@jpbempel jpbempel requested review from truthbk, tylerbenson and a team February 5, 2020 15:43
recoveryProcessor = new TaskProcessor(recoveryThreadPool, appConfig.getReporter());

collectionProcessor = new TaskProcessor(collectionThreadPool, appConfig.getReporter());
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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?

Copy link
Member Author

@jpbempel jpbempel Feb 8, 2020

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

Copy link
Member

@truthbk truthbk left a 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 {
Copy link
Member

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
@jpbempel jpbempel force-pushed the jpbempel/EmbeddedMode branch from e51cfa6 to 967c771 Compare February 12, 2020 07:49
@jpbempel jpbempel merged commit e51b840 into DataDog:master Feb 12, 2020
@jpbempel jpbempel deleted the jpbempel/EmbeddedMode branch February 12, 2020 07:56
@truthbk truthbk added this to the 0.35.0 milestone Feb 18, 2020
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.

3 participants