public LongMetric createLongMetric(@NonNull final String metricName, final long metricValue, @NonNull final Map<String, String> additionalTags) { final LongMetric metric = new LongMetric(metricName, metricValue); metric.addTags(getBaseTags()); metric.addTags(additionalTags); this.metricSet.add(metric); return metric; }
public LongMetric(@NotEmpty final String metricName, final long metricValue) { super(metricName, metricValue); this.addTag("metric-type", "long"); }
@Override public java.lang.String toString() { return java.lang.String.format("%s:startTime[%s]:endTime[%s]", super.toString(), this.startTime, this.endTime); }
private void calculateElapsed() { Preconditions.checkState(this.startTime.compareTo(this.endTime) <= 0); final Duration elapsed = Duration.between(startTime, endTime); log.info("{} elapsed {} milliseconds", this.metricName, elapsed.toMillis()); super.setMetricValue(elapsed.toMillis()); } }
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()); }
public LongMetric createJobLongMetric(@NonNull final JobMetricType metricType, final long metricValue, @NonNull final Map<String, String> additionalTags) { final LongMetric metric = new LongMetric(getMetricName(metricType), metricValue); metric.addTags(getBaseTags()); metric.addTags(additionalTags); this.metricSet.add(metric); return metric; }
private void reportStatus(final boolean successful) { final long statusValue = successful ? DataFeedMetricNames.RESULT_SUCCESS : DataFeedMetricNames.RESULT_FAILURE; final LongMetric successMetric = new LongMetric( DataFeedMetricNames.RESULT, statusValue); successMetric.addTags(this.dataFeedMetrics.getBaseTags()); this.reporters.report(successMetric); } }
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)); } }