MetricsWorkflowExecutorListener implements WorkflowExecutorListener { @Override public void afterFailure(ListenerContext context, Throwable exeption) { @SuppressWarnings("resource") Context timer = executionTimer(context); if (timer != null) { timer.close(); } metricRegistry.meter(stateMetricKey(context, "error-count")).mark(); } MetricsWorkflowExecutorListener(MetricRegistry metricRegistry, ExecutorDao executors); @Override void beforeProcessing(ListenerContext context); @Override void afterProcessing(ListenerContext context); @Override void afterFailure(ListenerContext context, Throwable exeption);  }
@Test public void afterFailure() { listener.beforeProcessing(context); listener.afterFailure(context, new Exception()); assertNotNull(metricRegistry.getHistograms().get("foobarName.0.myWorkflow.my-state.retries")); assertEquals(1, metricRegistry.getTimers().get("foobarName.0.myWorkflow.my-state.execution-time").getCount()); assertEquals(1, metricRegistry.getMeters().get("foobarName.0.myWorkflow.my-state.error-count").getCount()); }