-
Notifications
You must be signed in to change notification settings - Fork 275
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
Make CommonTaskExecutor
periodic tasks safe
#1366
Conversation
* Verify that we can schedule task and catch exceptions. This should help to avoid additional exceptions on app crash during startup. * Avoid holding strong references from within executor to make sure that things can get GCed.
3d25596
to
1fb844a
Compare
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.
A few comments...
utils/thread-utils/src/main/java/datadog/common/exec/CommonTaskExecutor.java
Outdated
Show resolved
Hide resolved
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/Cleaner.java
Outdated
Show resolved
Hide resolved
static final SpanCleanerTask INSTANCE = new SpanCleanerTask(); | ||
|
||
@Override | ||
public void run(final SpanCleaner target) { |
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.
Consider removing SpanCleaner
and have this accept the list of pendingTraces instead. (Implement the run
logic above directly.)
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.
if (cleaner != null) {
cleaner.close();
}
- this makes things somewhat more interesting since we cannot hold reference to pending traces inside the task.
Would it be ok if I add a fixme for now here - this seems less trivial change?
utils/thread-utils/src/main/java/datadog/common/exec/CommonTaskExecutor.java
Show resolved
Hide resolved
utils/thread-utils/src/main/java/datadog/common/exec/CommonTaskExecutor.java
Outdated
Show resolved
Hide resolved
utils/thread-utils/src/main/java/datadog/common/exec/CommonTaskExecutor.java
Outdated
Show resolved
Hide resolved
utils/thread-utils/src/main/java/datadog/common/exec/CommonTaskExecutor.java
Outdated
Show resolved
Hide resolved
Also move CleanerTest to PeriodicSchedulingTest
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.
Thanks for the cleanup!
This should help to avoid additional exceptions on app crash during
startup.
that things can get GCed.