Skip to content

Add GC name to gc pause metric - #3670

Merged
shakuzen merged 1 commit into
micrometer-metrics:mainfrom
lenin-jaganathan:gc_metrics
Mar 14, 2023
Merged

shakuzen merged 1 commit into
micrometer-metrics:mainfrom
lenin-jaganathan:gc_metrics

Conversation

@lenin-jaganathan

Copy link
Copy Markdown
Contributor

This is a follow-up PR for 3562. This intends to add the name of the Garbage collector to the "jvm.gc.pause" metric. Though this information might seem trivial for a single application, this really helps at the infrastructure level when 1000's of applications are running with different JDKs and different Gc configurations.

@shakuzen

shakuzen commented Mar 3, 2023

Copy link
Copy Markdown
Member

I like the idea and agree it would be very useful to have an identifier for the configured collector as a tag on the GC metrics. Unfortunately, I think the gcName on the notification is not necessarily quite what we want. From my previous investigations it has the following values. These correspond to the heap region and/or the gc phase, rather than being a single value identifying the garbage collector, which is what I think we would rather have. We could try to map from these to a collector name, but some share the same name across different collectors, and these names are not always stable across Java versions. It would be ideal if we could read the configured collector separately from these names, but I don't know of a way to do that.

G1GC
• G1 Young Generation
• G1 Old Generation

Serial
• Copy
• MarkSweepCompact

Parallel
• PS MarkSweep
• PS Scavenge

ZGC
• ZGC

Shenandoah
• Shenandoah Pauses
• Shenandoah Cycles

gencon
• scavenge
• global

balanced
• partial gc
• global garbage collect

optavgpause / optthruput
• global

metronome
• global

nogc
• Epsilon

@shakuzen shakuzen added enhancement A general enhancement module: micrometer-core An issue that is related to our core module labels Mar 3, 2023
@shakuzen shakuzen added this to the 1.11 backlog milestone Mar 3, 2023
@lenin-jaganathan

Copy link
Copy Markdown
Contributor Author

@shakuzen The list you shared is the ideal values I have intended for the tag "gc_name". The reasons for that instead of just "G1" - G1 Young Generation / G1 Old Generation makes more sense. We had more success with this in identifying whether the Gc is for the young gen or the old gen and the name of the Gc. Today, "jvm.gc.pause" has "action" which says whether it is the end of minor or major Gc or pause, and having the Gc name will make this gcAction less useful and we can have a single metric for both the scenarios.

@lenin-jaganathan

Copy link
Copy Markdown
Contributor Author

@shakuzen Also to add, "gc" falls under the OpenTelemetry Sematic Convention as well. Not sure how much of the OTEL convention matter in micrometer, but here is the OTEL convention on jvm metrics I.

Garbage collector name and action are generally obtained via GarbageCollectionNotificationInfo#getGcName() and GarbageCollectionNotificationInfo#getGcAction() respectively.

@shakuzen

Copy link
Copy Markdown
Member

Today, "jvm.gc.pause" has "action" which says whether it is the end of minor or major Gc or pause, and having the Gc name will make this gcAction less useful and we can have a single metric for both the scenarios.

I'm not sure I understood the point about action being less useful. That may be true in the specific case of G1GC with this new tag, but we need to support many GCs and the values used for each of these things varies and is not constant across versions of Java. It may have been better if we recorded the gc time for concurrent phases and stop-the-world phases using the same metric name and a tag separating them, but that would be a breaking change at this point for users relying on the current arrangement. We can consider that separately to this pull request if you think that would be useful.

The reasons for that instead of just "G1" - G1 Young Generation / G1 Old Generation makes more sense.

But the information about minor or major gc for g1gc is already contained in the action, so is it adding any useful information to have young/old in the gc name? Looking at other collectors, surely you can agree that global is not a better name than metronome or gencon. When looking at the metrics, people will not be able to distinguish between these because both will use global.

I would be interested to understand more about how this will be used operationally. What kinds of metric queries are you planning to use with this new tag that aren't possible currently or are difficult? Is it more about identifying the collector in use in each application or about comparing metrics values by collector?

I hope we can discuss the above more as I think this is important for making sure we're taking the right approach to provide information in the most useful way possible, and so we can understand and recommend a good approach to using this info to other users.
In the meantime, I think we can merge this feature as is for now so we can get it into a milestone and try to get wider feedback on it.

Thank you for providing the pull request and sharing your use case.

@shakuzen shakuzen modified the milestones: 1.11 backlog, 1.11.0-M2 Mar 14, 2023
@shakuzen
shakuzen merged commit f04464d into micrometer-metrics:main Mar 14, 2023
@lenin-jaganathan

Copy link
Copy Markdown
Contributor Author

@shakuzen The basic idea behind having the GC information in the metric is to evaluate the performance of the GCs and also to have insight into the Gc that is actually generating this metric. I agree that for a single application "action" makes sense about the minor/major cycles. But in a hybrid environment where we have around more than 2000 applications running with different Jdk and with different Gc's for the same Jdk, information about the GC itself makes more sense. We can derive if it is a major/minor GC from the Gc name but we cannot do the same with just "action".
I do agree that with more and more GCs coming into the picture and micrometer having wider usages, we can get a wider response from users and align this.

@shakuzen

Copy link
Copy Markdown
Member

You may also be interested in the JvmHeapPressureMetrics, which includes an approximation of gc overhead as a portion of CPU time.

It would be interesting to know what you plan to query in the metrics when evaluating GC performance. It sounds more like you want to query gc metrics and know what collector is configured (e.g. find high max pause time applications; then see what collector they're using). As opposed to querying metrics across all your applications filtered or grouped by collector (e.g. sum the pause time for each collector over the last 15 minutes). The former could be achieved by adding the collector name to jvm.info (assuming we figure out a way to get it), while the latter would be harder with many metrics backends without the label on the queried metric itself. That's why I'd be curious to have more insight into what kinds of queries into the metrics are most useful to users. I appreciate all that you've shared and contributed to Micrometer so far.

We can derive if it is a major/minor GC from the Gc name but we cannot do the same with just "action".

That's true for G1GC. It's not true for other collectors. You generally need to look at the name and action. One action can have multiple GC notifications meaning multiple GC metric recordings, potentially with different names even. It's also a general principle of dimensional metrics to not embed multiple pieces of different information (collector name / major or minor collection) in one tag. It shouldn't be a problem either to use multiple tags in querying metrics, so there is no reason it would hurt if the name tag actually was just the name and other tags had other information.

@lenin-jaganathan
lenin-jaganathan deleted the gc_metrics branch April 29, 2023 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement A general enhancement module: micrometer-core An issue that is related to our core module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants