Skip to content

mweirauch/micrometer-jvm-extras

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

155 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

micrometer-jvm-extras

A set of additional JVM process metrics for micrometer.io.

Apache License 2 Build status Quality Gate Status Coverage Maven Central

Motivation

  • get "real" memory usage of the JVM beyond its managed parts
  • get ahold of that info from within the JVM in environments where you can't instrument from the outside (e.g. PaaS)

Usage

<dependency>
  <groupId>io.github.mweirauch</groupId>
  <artifactId>micrometer-jvm-extras</artifactId>
  <version>x.y.z</version>
</dependency>
/* Plain Java */
final MeterRegistry registry = new SimpleMeterRegistry();
new ProcessMemoryMetrics().bindTo(registry);
new ProcessThreadMetrics().bindTo(registry);
/* With Spring */
@Bean
public MeterBinder processMemoryMetrics() {
    return new ProcessMemoryMetrics();
}

@Bean
public MeterBinder processThreadMetrics() {
    return new ProcessThreadMetrics();
}

Available Metrics

ProcessMemoryMetrics

ProcessMemoryMetrics reads process-level memory information from /proc/self/status and cgroup control files. All Meters are reporting in bytes.

Please note that procfs and the cgroup subsystem are only available on Linux-based systems.

Memory Usage

  • process.memory.vss: Virtual set size. The amount of virtual memory the process can access. Mostly irrelevant, but included for completeness sake.
  • process.memory.rss: Resident set size. The amount of process memory currently in RAM.
  • process.memory.swap: The amount of process memory paged out to swap.

Memory Limits

  • process.memory.limit.soft: Soft memory limit imposed by the cgroup.
  • process.memory.limit.hard: Hard memory limit imposed by the cgroup.
  • process.memory.limit.swap: Swap memory limit imposed by the cgroup. For cgroup v1 systems this value represents the total memory+swap limit, while for cgroup v2 systems it represents the swap limit only.

ProcessThreadMetrics

ProcessThreadMetrics reads process-level thread information from /proc/self/status.

Please note that procfs is only available on Linux-based systems.

  • process.threads: The number of process threads as seen by the operating system.
  • process.threads.context.switches.voluntary: The accumulated number of voluntary context switches since application start. A voluntary context switch occurs when a thread is in a waiting or blocked state and the scheduler switches control to another thread.
  • process.threads.context.switches.nonvoluntary: The accumulated number of non-voluntary context switches since application start. An involuntary context switch occurs when a thread consumed the whole time slice it was granted from the scheduler. The thread is suspended and control is switched to another thread.

Notes

  • Requires Java 8 or higher
  • This project strives to support a wider range of deployment scenarios. Thus the versions of micrometer-core and slf4j-api dependencies are chosen in a more defensive manner and don't necessarily reflect their latest available versions. Use your build and dependency management tool to manage the versions of these dependencies in your project.
  • Snapshot builds are pushed to Sonatype Maven Snapshots Repository on successful main builds.
  • procfs data is cached for 1000ms in order to relief the filesystem pressure when Meters based on this data are queried by the registry one after another on collection run.

About

A set of additional JVM process metrics for micrometer.io.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages