-
Notifications
You must be signed in to change notification settings - Fork 129
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
Implement GC duration metric #653
Conversation
jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/HandlerRegistry.java
Outdated
Show resolved
Hide resolved
@@ -50,6 +55,7 @@ static HandlerRegistry createDefault(MeterProvider meterProvider) { | |||
var seen = new HashSet<String>(); | |||
for (var bean : ManagementFactory.getGarbageCollectorMXBeans()) { | |||
var name = bean.getName(); | |||
garbageCollectors.add(name); |
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.
It's pretty tricky to tell which handlers get added in response to which garbage collectors. How about just a switch statement with cases for each known garbage collector bean name, where each case explicitly registers its required handlers?
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 think that's a good idea. Implemented suggestion.
...pentelemetry/contrib/jfr/metrics/internal/GarbageCollection/OldGarbageCollectionHandler.java
Outdated
Show resolved
Hide resolved
...pentelemetry/contrib/jfr/metrics/internal/GarbageCollection/OldGarbageCollectionHandler.java
Outdated
Show resolved
Hide resolved
jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/HandlerRegistry.java
Outdated
Show resolved
Hide resolved
jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/HandlerRegistry.java
Show resolved
Hide resolved
jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/HandlerRegistry.java
Outdated
Show resolved
Hide resolved
@@ -72,7 +86,8 @@ static HandlerRegistry createDefault(MeterProvider meterProvider) { | |||
new ContainerConfigurationHandler(), | |||
new LongLockHandler(grouper), | |||
new ThreadCountHandler(), | |||
new ClassesLoadedHandler()); | |||
new ClassesLoadedHandler(), | |||
new OldGarbageCollectionHandler(garbageCollectors)); |
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.
These could be added in the switch statement as well. Instead of passing the set of garbageCollectors
you could pass the name of the garbage collector as a constructor argument.
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.
This is a good idea. It also allows us to get rid of the set caching all the GC types. Done!
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.
One last simplification
...pentelemetry/contrib/jfr/metrics/internal/GarbageCollection/OldGarbageCollectionHandler.java
Outdated
Show resolved
Hide resolved
...ntelemetry/contrib/jfr/metrics/internal/GarbageCollection/YoungGarbageCollectionHandler.java
Outdated
Show resolved
Hide resolved
…cs/internal/GarbageCollection/OldGarbageCollectionHandler.java Co-authored-by: jack-berg <34418638+jack-berg@users.noreply.github.com>
…cs/internal/GarbageCollection/YoungGarbageCollectionHandler.java Co-authored-by: jack-berg <34418638+jack-berg@users.noreply.github.com>
Description:
This PR adds changes that implement the metric
process.runtime.jvm.gc.duration
.This was a part of a larger PR here: #644.
jfr-streaming/src/main/java/io/opentelemetry/contrib/jfr/metrics/internal/Constants.java
has been kept the same as it was in the larger PR because it's used in all of the smaller constituent PRs. This will hopefully also avoid some conflicts as the PRs are sequentially merged. As a result, there are some constants that are defined, but not used in this PR.Testing:
Tests were added but they don't have great coverage. In the future we need to devise a reliable way to test each GC. Currently, I'm not sure of a way to change GCs at runtime in order to test them all. I'm also uncertain of how to reliably force young gen GC and old gen GC. As a result, the test added in this PR basically just invokes "some" GC and ensures that the resulting metric has data that is expected.