-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add Gauges for memory usage after GC #7296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |
| */ | ||
| package io.micrometer.core.instrument.binder.jvm.convention; | ||
|
|
||
| import io.micrometer.core.instrument.Tags; | ||
| import io.micrometer.core.instrument.binder.MeterConvention; | ||
|
|
||
| import java.lang.management.MemoryPoolMXBean; | ||
|
|
@@ -33,4 +34,33 @@ public interface JvmMemoryMeterConventions { | |
|
|
||
| MeterConvention<MemoryPoolMXBean> getMemoryMaxConvention(); | ||
|
|
||
| /** | ||
| * Convention for JVM memory used after last GC. | ||
| * @return convention for JVM memory used after last GC | ||
| * @since 1.17.0 | ||
| */ | ||
| default JvmMemoryUsedAfterLastGcConvention getMemoryUsedAfterLastGcConvention() { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While other methods here have return type
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we create an issue for 2.x? |
||
| return new JvmMemoryUsedAfterLastGcConvention() { | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * {@link MeterConvention} for JVM memory used after last GC. | ||
| * | ||
| * @since 1.17.0 | ||
| */ | ||
| interface JvmMemoryUsedAfterLastGcConvention extends MeterConvention<MemoryPoolMXBean> { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if it would be better to make this a top level type - it can be a bit annoying to reference it as
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Grouping makes sense to me. Not sure how well-known it is but if people annoyed by using import static io.micrometer.core.instrument.binder.jvm.convention.JvmMemoryMeterConventions.JvmMemoryUsedAfterLastGcConvention;and use only |
||
|
|
||
| @Override | ||
| default String getName() { | ||
| return "jvm.memory.used_after_last_gc"; | ||
| } | ||
|
|
||
| @Override | ||
| default Tags getTags(MemoryPoolMXBean memoryPoolBean) { | ||
| return Tags.empty(); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default implementation is not useful, but it was needed since we can't add a new non-default method to the |
||
| } | ||
|
|
||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did have a version of this code that registered pools even if this returns null, but they always have the value
NaNwhich didn't seem worthwhile registering.