MetricsWorkflowExecutorListener implements WorkflowExecutorListener { @Override public void beforeProcessing(ListenerContext context) { @SuppressWarnings("resource") Context timerContext = metricRegistry.timer( stateMetricKey(context, "execution-time")).time(); context.data.put(EXECUTION_KEY, timerContext); meterRetries(context); meterStartupDelay(context); } 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 whenNextActivationIsSetToNullBeforeContext() { listener.beforeProcessing(context); assertEquals(1, metricRegistry.getHistograms().get("foobarName.0.myWorkflow.my-state.retries").getCount()); assertNotNull(metricRegistry.getTimers().get("foobarName.0.myWorkflow.my-state.execution-time")); assertNull(metricRegistry.getHistograms().get("foobarName.0.startup-delay")); }
@Test public void beforeContext() { listener.beforeProcessing(context2); assertEquals(1, metricRegistry.getHistograms().get("foobarName.0.myWorkflow.my-state.retries").getCount()); assertNotNull(metricRegistry.getTimers().get("foobarName.0.myWorkflow.my-state.execution-time")); assertNotNull(metricRegistry.getHistograms().get("foobarName.0.startup-delay")); }