From 78d7f549d386bd7f2b78c3d7bd954440d6aa525b Mon Sep 17 00:00:00 2001 From: Henry Chen Date: Tue, 26 May 2026 13:19:50 -0400 Subject: [PATCH] Observability: Clean up Oshi No longer need Oshi to send system metrics to Prometheus, since we can directly monitor system resource usage of kubernetes nodes. Keeping the commit sha, since it's still included in all of the metrics generated by Spring Actuator. --- pom.xml | 5 ---- .../utilities/SystemMetricsConfig.java | 29 ++++++------------- 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/pom.xml b/pom.xml index 11b7fe7c3..f086ab06f 100644 --- a/pom.xml +++ b/pom.xml @@ -191,11 +191,6 @@ io.micrometer micrometer-registry-prometheus - - com.github.oshi - oshi-core - 6.6.6 - org.springframework.boot spring-boot-starter-jdbc diff --git a/src/main/java/org/patinanetwork/codebloom/utilities/SystemMetricsConfig.java b/src/main/java/org/patinanetwork/codebloom/utilities/SystemMetricsConfig.java index 16aa8b1df..8db6d5a21 100644 --- a/src/main/java/org/patinanetwork/codebloom/utilities/SystemMetricsConfig.java +++ b/src/main/java/org/patinanetwork/codebloom/utilities/SystemMetricsConfig.java @@ -7,18 +7,21 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import oshi.SystemInfo; -import oshi.hardware.GlobalMemory; +/** + * Configuration for system metrics exposed to Prometheus through Spring Actuator. + * Prometheus ingests the metrics from Actuator through a Kubernetes object defined in the k8s-manifest. + * + * @see Service Monitor + */ @Configuration @EnableConfigurationProperties(CommitShaProperties.class) public class SystemMetricsConfig { - @Bean - public SystemInfo systemInfo() { - return new SystemInfo(); - } + /** + * Add commit sha to metrics so that the deployed version of the code being run on the instance is known. + */ @Bean public MeterBinder applicationInfoMetrics(CommitShaProperties commitShaProperties) { return registry -> { @@ -26,18 +29,4 @@ public MeterBinder applicationInfoMetrics(CommitShaProperties commitShaPropertie registry.gauge("application.info", tags, 1, n -> 1.0); }; } - - @Bean - public MeterBinder systemMemoryMetrics(SystemInfo systemInfo) { - return registry -> { - GlobalMemory memory = systemInfo.getHardware().getMemory(); - registry.gauge("system.info.memory.total", memory, GlobalMemory::getTotal); - registry.gauge("system.info.memory.available", memory, GlobalMemory::getAvailable); - registry.gauge("system.info.memory.used", memory, m -> m.getTotal() - m.getAvailable()); - registry.gauge( - "system.info.memory.usage", - memory, - m -> (double) (m.getTotal() - m.getAvailable()) / m.getTotal() * 100); - }; - } }