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

Handle exceptions at sampling runnable level. #93

Merged
merged 1 commit into from
Aug 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,26 @@ static class SamplerRunnable implements Runnable {
private final Logger logger = LoggerFactory.getLogger(SamplerRunnable.class);

private final Sampler sampler;
private int failureCount = 0;

SamplerRunnable(Sampler sampler) {
this.sampler = sampler;
}

@Override
public void run() {
logger.trace("Executing operation {}", sampler);
sampler.fetch();
try {
logger.trace("Executing operation {}", sampler);
sampler.fetch();
} catch (Exception e) {
if (failureCount++ == 0) {
logger.warn("Failed to collect sample", e);
} else if (failureCount < 1000 && failureCount % 100 == 0) {
logger.warn("Failed to collect sample. This is {} failure of this task", failureCount, e);
} else if (failureCount >= 1000 && failureCount % 1000 == 0) {
logger.warn("Failed to collect sample. This is {} failure of this task, possible permanent communication error", failureCount, e);
}
}
}
}
}
Loading