mirror of https://github.com/apache/nifi.git
NIFI-2309 Correcting AmbariReportingTask so it reports total task duration as seconds and as nano-seconds
This closes #672 Signed-off-by: jpercivall <joepercivall@yahoo.com>
This commit is contained in:
parent
deb2819bfb
commit
8e2663c54d
|
@ -31,7 +31,8 @@ public interface MetricNames {
|
||||||
String BYTES_READ = "BytesReadLast5Minutes";
|
String BYTES_READ = "BytesReadLast5Minutes";
|
||||||
String BYTES_WRITTEN = "BytesWrittenLast5Minutes";
|
String BYTES_WRITTEN = "BytesWrittenLast5Minutes";
|
||||||
String ACTIVE_THREADS = "ActiveThreads";
|
String ACTIVE_THREADS = "ActiveThreads";
|
||||||
String TOTAL_TASK_DURATION = "TotalTaskDurationSeconds";
|
String TOTAL_TASK_DURATION_SECONDS = "TotalTaskDurationSeconds";
|
||||||
|
String TOTAL_TASK_DURATION_NANOS = "TotalTaskDurationNanoSeconds";
|
||||||
|
|
||||||
// JVM Metrics
|
// JVM Metrics
|
||||||
String JVM_UPTIME = "jvm.uptime";
|
String JVM_UPTIME = "jvm.uptime";
|
||||||
|
|
|
@ -46,7 +46,13 @@ public class MetricsService {
|
||||||
metrics.put(MetricNames.BYTES_READ, String.valueOf(status.getBytesRead()));
|
metrics.put(MetricNames.BYTES_READ, String.valueOf(status.getBytesRead()));
|
||||||
metrics.put(MetricNames.BYTES_WRITTEN, String.valueOf(status.getBytesWritten()));
|
metrics.put(MetricNames.BYTES_WRITTEN, String.valueOf(status.getBytesWritten()));
|
||||||
metrics.put(MetricNames.ACTIVE_THREADS, String.valueOf(status.getActiveThreadCount()));
|
metrics.put(MetricNames.ACTIVE_THREADS, String.valueOf(status.getActiveThreadCount()));
|
||||||
metrics.put(MetricNames.TOTAL_TASK_DURATION, String.valueOf(calculateProcessingNanos(status)));
|
|
||||||
|
final long durationNanos = calculateProcessingNanos(status);
|
||||||
|
metrics.put(MetricNames.TOTAL_TASK_DURATION_NANOS, String.valueOf(durationNanos));
|
||||||
|
|
||||||
|
final long durationSeconds = TimeUnit.SECONDS.convert(durationNanos, TimeUnit.NANOSECONDS);
|
||||||
|
metrics.put(MetricNames.TOTAL_TASK_DURATION_SECONDS, String.valueOf(durationSeconds));
|
||||||
|
|
||||||
return metrics;
|
return metrics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,8 @@ public class TestMetricsService {
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_READ));
|
Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_READ));
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_WRITTEN));
|
Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_WRITTEN));
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.ACTIVE_THREADS));
|
Assert.assertTrue(metrics.containsKey(MetricNames.ACTIVE_THREADS));
|
||||||
Assert.assertTrue(metrics.containsKey(MetricNames.TOTAL_TASK_DURATION));
|
Assert.assertTrue(metrics.containsKey(MetricNames.TOTAL_TASK_DURATION_SECONDS));
|
||||||
|
Assert.assertTrue(metrics.containsKey(MetricNames.TOTAL_TASK_DURATION_NANOS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue