janhoy commented on code in PR #4209:
URL: https://github.com/apache/solr/pull/4209#discussion_r2927984989


##########
solr/core/src/java/org/apache/solr/metrics/OtelRuntimeJvmMetrics.java:
##########
@@ -65,6 +75,38 @@ public ContextPropagators getPropagators() {
             // TODO: We should have this configurable to enable/disable 
specific JVM metrics
             .enableAllFeatures()
             .build();
+    java.lang.management.OperatingSystemMXBean osMxBean =
+        ManagementFactory.getOperatingSystemMXBean();
+    if (osMxBean instanceof com.sun.management.OperatingSystemMXBean 
extOsMxBean) {
+      systemMemoryTotalGauge =
+          solrMetricManager.observableLongGauge(
+              registryName,
+              "jvm.system.memory",
+              "Total physical memory of the host or container in bytes."
+                  + " On Linux with cgroup limits, reflects the container 
memory limit.",
+              measurement -> {
+                long total = extOsMxBean.getTotalMemorySize();
+                if (total > 0) measurement.record(total);
+              },
+              OtelUnit.BYTES);
+      systemMemoryFreeGauge =
+          solrMetricManager.observableLongGauge(
+              registryName,
+              "jvm.system.memory.free",
+              "Free (unused) physical memory of the host or container in 
bytes.",
+              measurement -> {
+                long free = extOsMxBean.getFreeMemorySize();
+                if (free > 0) measurement.record(free);
+              },
+              OtelUnit.BYTES);

Review Comment:
   Yea. Currently we do not have a separate panel for system memory, but could 
add one. Personally I hate it when one panel displays 5 graphs per JVM/node 
which say very different things, like max, min, free, used. In the new 
dashboard I therefore try to have one panel for used and another for free. 
   
   But even if we merge these into one metric key (I think we should) it is 
easy to make one or two panels on the visualization layer. What about a panel 
that shows total-system-mem, heap-max and system-free in the same panel as 
stacked area graph? Then we'd see the node's total mem and how it is divided 
between heap, off-heap (where mmap is largest) and free.
   
   As for naming, `jvm.system.memory` is ok, with an attribute `total` one 
`free`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to