NIFI-8317 heap and non_heap usage Prometheus metrics now return -1.0 when undefined.

Signed-off-by: Matthew Burgess <mattyb149@apache.org>

This closes #4920
This commit is contained in:
noblenumbat360 2021-03-22 13:08:49 +11:00 committed by Matthew Burgess
parent 02ea103c6b
commit ee1386db02
No known key found for this signature in database
GPG Key ID: 05D3DEB8126DAD24
1 changed files with 4 additions and 2 deletions

View File

@ -139,12 +139,14 @@ public class JmxJvmMetrics implements JvmMetrics {
@Override
public double heapUsage() {
return (Double) getMetric(MEMORY_HEAP_USAGE);
double usage = (Double) getMetric(MEMORY_HEAP_USAGE);
return usage < 0 ? -1.0 : usage;
}
@Override
public double nonHeapUsage() {
return (Double) getMetric(MEMORY_NON_HEAP_USAGE);
double usage = (Double) getMetric(MEMORY_NON_HEAP_USAGE);
return usage < 0 ? -1.0 : usage;
}
@Override