aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHÃ¥kon Hallingstad <hakon@verizonmedia.com>2020-12-01 16:34:48 +0100
committerGitHub <noreply@github.com>2020-12-01 16:34:48 +0100
commitd495adc5cf2ba71f79745fab376981d1fae918df (patch)
treee821ab4d7531ca745798e9402449024c9259cde0
parentab8072ce5f98b3f95914c58c815f21b41192e531 (diff)
parent4745cc3125f61ae5926a02734424c816b1192374 (diff)
Merge pull request #15567 from vespa-engine/hakonhall/do-not-print-0-fields-in-the-locks-response
Do not print 0 fields in the locks response
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/LocksResponse.java61
1 files changed, 34 insertions, 27 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/LocksResponse.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/LocksResponse.java
index 6f1334421ef..0f9babb53aa 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/LocksResponse.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/LocksResponse.java
@@ -51,26 +51,6 @@ public class LocksResponse extends HttpResponse {
root.setString("hostname", hostname);
root.setString("time", Instant.now().toString());
- Cursor lockPathsCursor = root.setArray("lock-paths");
- lockMetricsByPath.forEach((lockPath, lockMetrics) -> {
- Cursor lockPathCursor = lockPathsCursor.addObject();
- lockPathCursor.setString("path", lockPath);
- lockPathCursor.setLong("acquireCount", lockMetrics.getCumulativeAcquireCount());
- lockPathCursor.setLong("acquireFailedCount", lockMetrics.getCumulativeAcquireFailedCount());
- lockPathCursor.setLong("acquireTimedOutCount", lockMetrics.getCumulativeAcquireTimedOutCount());
- lockPathCursor.setLong("lockedCount", lockMetrics.getCumulativeAcquireSucceededCount());
- lockPathCursor.setLong("releaseCount", lockMetrics.getCumulativeReleaseCount());
- lockPathCursor.setLong("releaseFailedCount", lockMetrics.getCumulativeReleaseFailedCount());
- lockPathCursor.setLong("reentryCount", lockMetrics.getCumulativeReentryCount());
- lockPathCursor.setLong("deadlock", lockMetrics.getCumulativeDeadlockCount());
- lockPathCursor.setLong("nakedRelease", lockMetrics.getCumulativeNakedReleaseCount());
- lockPathCursor.setLong("acquireWithoutRelease", lockMetrics.getCumulativeAcquireWithoutReleaseCount());
- lockPathCursor.setLong("foreignRelease", lockMetrics.getCumulativeForeignReleaseCount());
-
- setLatency(lockPathCursor, "acquire", lockMetrics.getAcquireLatencyMetrics());
- setLatency(lockPathCursor, "locked", lockMetrics.getLockedLatencyMetrics());
- });
-
Cursor threadsCursor = root.setArray("threads");
for (var threadLockStats : threadLockStatsList) {
Optional<LockAttempt> ongoingLockAttempt = threadLockStats.getTopMostOngoingLockAttempt();
@@ -102,18 +82,45 @@ public class LocksResponse extends HttpResponse {
Cursor recordingsCursor = root.setArray("recordings");
historicRecordings.forEach(recording -> setRecording(recordingsCursor.addObject(), recording));
}
+
+ Cursor lockPathsCursor = root.setArray("lock-paths");
+ lockMetricsByPath.forEach((lockPath, lockMetrics) -> {
+ Cursor lockPathCursor = lockPathsCursor.addObject();
+ lockPathCursor.setString("path", lockPath);
+ setNonZeroLong(lockPathCursor, "acquireCount", lockMetrics.getCumulativeAcquireCount());
+ setNonZeroLong(lockPathCursor, "acquireFailedCount", lockMetrics.getCumulativeAcquireFailedCount());
+ setNonZeroLong(lockPathCursor, "acquireTimedOutCount", lockMetrics.getCumulativeAcquireTimedOutCount());
+ setNonZeroLong(lockPathCursor, "lockedCount", lockMetrics.getCumulativeAcquireSucceededCount());
+ setNonZeroLong(lockPathCursor, "releaseCount", lockMetrics.getCumulativeReleaseCount());
+ setNonZeroLong(lockPathCursor, "releaseFailedCount", lockMetrics.getCumulativeReleaseFailedCount());
+ setNonZeroLong(lockPathCursor, "reentryCount", lockMetrics.getCumulativeReentryCount());
+ setNonZeroLong(lockPathCursor, "deadlock", lockMetrics.getCumulativeDeadlockCount());
+ setNonZeroLong(lockPathCursor, "nakedRelease", lockMetrics.getCumulativeNakedReleaseCount());
+ setNonZeroLong(lockPathCursor, "acquireWithoutRelease", lockMetrics.getCumulativeAcquireWithoutReleaseCount());
+ setNonZeroLong(lockPathCursor, "foreignRelease", lockMetrics.getCumulativeForeignReleaseCount());
+
+ setLatency(lockPathCursor, "acquire", lockMetrics.getAcquireLatencyMetrics());
+ setLatency(lockPathCursor, "locked", lockMetrics.getLockedLatencyMetrics());
+ });
+ }
+
+ private static void setNonZeroLong(Cursor cursor, String fieldName, long value) {
+ if (value != 0) {
+ cursor.setLong(fieldName, value);
+ }
}
private static void setLatency(Cursor cursor, String name, LatencyMetrics latencyMetrics) {
- cursor.setDouble(name + "Latency", latencyMetrics.latencySeconds());
- cursor.setDouble(name + "MaxActiveLatency", latencyMetrics.maxActiveLatencySeconds());
- cursor.setDouble(name + "Hz", latencyMetrics.endHz());
- cursor.setDouble(name + "Load", latencyMetrics.load());
+ setNonZeroDouble(cursor, name + "Latency", latencyMetrics.latencySeconds());
+ setNonZeroDouble(cursor, name + "MaxActiveLatency", latencyMetrics.maxActiveLatencySeconds());
+ setNonZeroDouble(cursor, name + "Hz", latencyMetrics.endHz());
+ setNonZeroDouble(cursor, name + "Load", latencyMetrics.load());
}
- private static double roundDouble(double value, int decimalPlaces) {
- double factor = Math.pow(10, decimalPlaces);
- return Math.round(value * factor) / factor;
+ private static void setNonZeroDouble(Cursor cursor, String fieldName, double value) {
+ if (Double.compare(value, 0.0) != 0) {
+ cursor.setDouble(fieldName, value);
+ }
}
@Override