https://github.com/mweirauch/micrometer-jvm-extras
A set of additional JVM process metrics for micrometer.io.
https://github.com/mweirauch/micrometer-jvm-extras
java jvm metrics micrometer
Last synced: 8 months ago
JSON representation
A set of additional JVM process metrics for micrometer.io.
- Host: GitHub
- URL: https://github.com/mweirauch/micrometer-jvm-extras
- Owner: mweirauch
- License: apache-2.0
- Created: 2017-09-20T20:35:13.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2024-11-11T12:51:44.000Z (over 1 year ago)
- Last Synced: 2025-07-26T14:40:31.345Z (11 months ago)
- Topics: java, jvm, metrics, micrometer
- Language: Java
- Size: 142 KB
- Stars: 160
- Watchers: 5
- Forks: 20
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-java - Micrometer JVM Extras
- awesome - mweirauch/micrometer-jvm-extras - A set of additional JVM process metrics for micrometer.io. (<a name="Java"></a>Java)
README
# micrometer-jvm-extras
A set of additional JVM process metrics for [micrometer.io](https://micrometer.io/).
[](https://raw.githubusercontent.com/mweirauch/micrometer-jvm-extras/main/LICENSE)
[](https://github.com/mweirauch/micrometer-jvm-extras/actions?query=workflow%3ACI+branch%3Amain)
[](https://sonarcloud.io/dashboard?id=mweirauch_micrometer-jvm-extras)
[](https://sonarcloud.io/dashboard?id=mweirauch_micrometer-jvm-extras)
[](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22io.github.mweirauch%22%20AND%20a%3A%22micrometer-jvm-extras%22)
## 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
```xml
io.github.mweirauch
micrometer-jvm-extras
x.y.z
```
```java
/* Plain Java */
final MeterRegistry registry = new SimpleMeterRegistry();
new ProcessMemoryMetrics().bindTo(registry);
new ProcessThreadMetrics().bindTo(registry);
```
```java
/* 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`.
All `Meter`s are reporting in `bytes`.
> Please note that `procfs` is only available on Linux-based systems.
* `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.
### 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
* `procfs` data is cached for `1000ms` in order to relief the filesystem pressure
when `Meter`s based on this data are queried by the registry one after
another on collection run.
* Snapshot builds are pushed to [Sonatype Nexus Snapshot Repository](https://oss.sonatype.org/content/repositories/snapshots/io/github/mweirauch/micrometer-jvm-extras/) on successful `main` builds.