Skip to content

Commit

Permalink
[saga] Add timers
Browse files Browse the repository at this point in the history
  • Loading branch information
jrousseau committed Mar 4, 2016
1 parent 1391ece commit 2be4861
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,24 +206,27 @@ protected void persistSaga(final Step step, final Object sagaIdentifier, final S
}

protected void persistSaga(final Object sagaIdentifier, final Saga saga, final boolean endSaga) {
long startTime = System.nanoTime();
if (endSaga) {
Timer.Context endTimer = KasperMetrics.getMetricRegistry().timer(KasperMetrics.name(saga.getClass(), "end-handle-time")).time();
try {
repository.delete(saga.getClass(), sagaIdentifier);

for (final Step aStep : steps.values()) {
Timer.Context endTimerStep = KasperMetrics.getMetricRegistry().timer(KasperMetrics.name(saga.getClass(), sagaIdentifier.toString() + "." + aStep.name() + "-step-handle-time")).time();
Timer.Context endTimerSteps = KasperMetrics.getMetricRegistry().timer(KasperMetrics.name(saga.getClass(), saga.getClass().getSimpleName() + "." + aStep.name() + ".end-handle-time")).time();
aStep.clean(sagaIdentifier);
endTimerStep.stop();
endTimerSteps.stop();
}
} catch (Exception e) {
throw new SagaExecutionException(
String.format("Unexpected error in deleting saga, <saga=%s> <identifier=%s>", saga.getClass(), sagaIdentifier),
e
);
} finally {
long endTime = System.nanoTime();
LOGGER.info(String.format("[SagaExecutor][End] Process time %d ms", (endTime - startTime)/1000000));
endTimer.stop();
}
}

} else {
try {
Expand All @@ -233,6 +236,9 @@ protected void persistSaga(final Object sagaIdentifier, final Saga saga, final b
String.format("Unexpected error in saving saga, <saga=%s> <identifier=%s>", saga.getClass(), sagaIdentifier),
e
);
}finally {
long endTime = System.nanoTime();
LOGGER.info(String.format("[SagaExecutor][Save] Process time %d ms", (endTime - startTime)/1000000));
}
}
}
Expand Down

0 comments on commit 2be4861

Please sign in to comment.