janhoy commented on code in PR #4209:
URL: https://github.com/apache/solr/pull/4209#discussion_r2927881538
##########
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);
Review Comment:
Theoretical, since it is byte. You might have it for a split second but then
it will fluctuate. I'm not sure enough about the behavior of all JVMs, if any
would return 0 as "don't know" - my LLM obviously thought so and chose to play
safe.
Let's consider `>= 0` instead for both, since `-1` seems to be the expected
value for no value...
--
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]