public void report(final Metric m) { // Todo T1137075 - Figure out how to report metrics from spark executor side if (this.reporters.isEmpty()) { throw new JobRuntimeException("No reporters registered"); } this.reporters.forEach(r -> r.gauge(m)); }
private void reportExecuteTime(@NonNull final IJobDagAction action, final long timeInMillis) { final LongMetric timeMetric = new LongMetric(TIME_METRIC, TimeUnit.MILLISECONDS.toSeconds(timeInMillis)); timeMetric.addTags(action.getMetricTags()); this.reporters.getReporters().stream().forEach(r -> r.gauge(timeMetric)); }
private void reportActionStatus(@NonNull final IJobDagAction action, final boolean isSuccess) { final LongMetric resultMetric = new LongMetric(RESULT_METRIC, isSuccess ? RESULT_SUCCESS : RESULT_FAILURE); resultMetric.addTags(action.getMetricTags()); this.reporters.getReporters().stream().forEach(r -> r.gauge(resultMetric)); } }
private void verifyJobMetricResult(@NonNull final IJobDagAction jobDagAction, final boolean dagSuccess, final long expectedMetricValue, final boolean isFailureExpected) { final Reporters reporters = new Reporters(); final IReporter mockReporter = spy(new TestReporter()); reporters.addReporter(mockReporter); final JobDagActions jobDagActions = new JobDagActions(reporters); jobDagActions.addAction(jobDagAction); Assert.assertEquals(!isFailureExpected, jobDagActions.execute(dagSuccess)); final ArgumentCaptor<LongMetric> metricCapture = ArgumentCaptor.forClass(LongMetric.class); verify(mockReporter, times(2)).gauge(metricCapture.capture()); Assert.assertEquals(expectedMetricValue, metricCapture.getValue().getMetricValue().longValue()); }