Skip to content

Commit

Permalink
Stop timers appropriately
Browse files Browse the repository at this point in the history
  • Loading branch information
sebr72 authored and sbrunner committed Jun 11, 2024
1 parent 5569636 commit ed172bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,7 @@ protected Values compute() {
.mdcContext(
() -> {
final Values values = this.execContext.getValues();

final Processor<In, Out> process = this.node.processor;
final String timerName =
String.format(
"%s.compute.%s",
ProcessorGraphNode.class.getName(), process.getClass().getName());
executeProcess(process, values, timerName);

executeProcess(this.node.processor, values);
this.execContext.getContext().stopIfCanceled();
ProcessorDependencyGraph.tryExecuteNodes(
this.node.dependencies, this.execContext, true);
Expand All @@ -187,8 +180,10 @@ protected Values compute() {
});
}

private void executeProcess(
final Processor<In, Out> process, final Values values, final String timerName) {
private void executeProcess(final Processor<In, Out> process, final Values values) {
final String timerName =
String.format(
"%s.compute.%s", ProcessorGraphNode.class.getName(), process.getClass().getName());
final Timer.Context timerContext = this.node.metricRegistry.timer(timerName).time();
try {
final In inputParameter = ProcessorUtils.populateInputParameter(process, values);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ File compileJasperReport(final File buildFile, final File jasperFile) throws JRE
// of once.
LOGGER.info("Building Jasper report: {}", jasperFile.getAbsolutePath());
LOGGER.debug("To: {}", buildFile.getAbsolutePath());
final String timerName = getClass().getName() + ".compile." + jasperFile;
try (Timer.Context compileJasperReport = this.metricRegistry.timer(timerName).time()) {
doCompileAndMoveReport(buildFile, jasperFile, compileJasperReport);
}
doCompileAndMoveReport(buildFile, jasperFile);
} catch (IOException e) {
throw new JRException(e);
}
Expand All @@ -94,11 +91,12 @@ File compileJasperReport(final File buildFile, final File jasperFile) throws JRE
return buildFile;
}

private static void doCompileAndMoveReport(
final File buildFile, final File jasperFile, final Timer.Context compileTimerContext)
private void doCompileAndMoveReport(final File buildFile, final File jasperFile)
throws JRException, IOException {
final File tmpBuildFile =
File.createTempFile("temp_", JASPER_REPORT_COMPILED_FILE_EXT, buildFile.getParentFile());
final String timerName = getClass().getName() + ".compile." + jasperFile;
Timer.Context compileTimerContext = this.metricRegistry.timer(timerName).time();
try {
JasperCompileManager.compileReportToFile(
jasperFile.getAbsolutePath(), tmpBuildFile.getAbsolutePath());
Expand Down

0 comments on commit ed172bf

Please sign in to comment.