Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,6 @@
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>com.github.oshi</groupId>
<artifactId>oshi-core</artifactId>
<version>6.6.6</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,16 @@
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
@EnableConfigurationProperties(CommitShaProperties.class)
public class SystemMetricsConfig {

@Bean
public SystemInfo systemInfo() {
return new SystemInfo();
}

@Bean
public MeterBinder applicationInfoMetrics(CommitShaProperties commitShaProperties) {
return registry -> {
var tags = Tags.of(Tag.of("sha", commitShaProperties.getSha()));
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);
};
}
}
Loading