-
Couldn't load subscription status.
- Fork 161
Fixes in monitoring, enable monitoring in Embedded GlassFish #25752
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: master
Are you sure you want to change the base?
Fixes in monitoring, enable monitoring in Embedded GlassFish #25752
Conversation
Requires running with flashlight-agent on command line with -javaagent:flashlight-agent.jar When started with command "enable-monitoring --mbean true", metric will be available via JMX beans
Needed for monitoring, at least in Embedded GlassFish. Otherwise: java.lang.reflect.InaccessibleObjectException: Unable to make public java.util.Enumeration jdk.internal.loader.BuiltinClassLoader.findResources(java.lang.String) throws java.io.IOException accessible: module java.base does not "exports jdk.internal.loader" to unnamed module @1de0aca6 at java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:391) at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:367) at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:315) at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:203) at java.base/java.lang.reflect.Method.setAccessible(Method.java:197) at com.sun.enterprise.module.single.ManifestProxy.<init>(ManifestProxy.java:71) at com.sun.enterprise.module.single.ProxyModuleDefinition.generate(ProxyModuleDefinition.java:146) at com.sun.enterprise.module.single.ProxyModuleDefinition.getManifest(ProxyModuleDefinition.java:134) at org.glassfish.admin.monitor.MonitoringBootstrap.addProvider(MonitoringBootstrap.java:298)
f7871b9 to
6c3eff8
Compare
d4bdf73 to
28dd44c
Compare
Disable test for Embedded Web - it doesn't support AMX because it doesn't include glassfish-mbeanserver artifact.
28dd44c to
0a14238
Compare
- do not unregister probes when deleting listener, unless it's the last listener - count busy threads in the monitor and pass info to stats (maybe not necessary) - catch out of bounds exception in probes, which sometimes happens, probably because of a probe is removed concurrently from the array while iterating through the collection - global stats updates with the setCurrentThreadCountEvent event
...us/flashlight/framework/src/main/java/org/glassfish/flashlight/provider/FlashlightProbe.java
Outdated
Show resolved
Hide resolved
| <plugins> | ||
| <plugin> | ||
| <groupId>org.codehaus.gmaven</groupId> | ||
| <artifactId>groovy-maven-plugin</artifactId> |
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 would prefer using java and exec plugin; not sure if it is doable.
The groovy is not so well readable for us and we tend to do evil things: catching exceptions without processing them, closing jars just when their processing doesn't throw exceptions instead of try-with ...
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 was lazy here and asked AI. It couldn't figure out how to do it using Ant. It kept suggesting using exec plugin with a shell script, which obviously wouldn't work on Windows. Then I decided to use Groovy, which works everywhere. Another option would be to create a new maven plugin, but that would have to be a separate project, or part of the buildhelper plugin, which is external and we would have to release it first.
Another option is to create a script in Java and execute it via the exec plugin, maybe that's what you mean. If we can compile it first or execute it directly as a script, then it should work too.
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 tried. It's just too complicated. Groovy script is the best option. The only other option is to create a separate maven plugin, because we need to set a maven project property, which is used in another plugin to build the final MANIFEST. And I don't want to bother with a separate Maven plugin. The Groovy script is almost like Java and it's pretty simple.
Also adds tests for it. Also adds support for a system property glassfish.remote, to run tests against a remote server instead of setting up a local (managed) one and stopping it after tests. This helps in debugging test scenarios.
82cfb22 to
4575b83
Compare
Introduced by a previous "fix" :)
4575b83 to
dc4c6e7
Compare
Ensures that the reported current thread count and busy thread count is exactly the number of threads reported by the pool. Even if monitoring is started while thread pool is actively processing requests.
A few improvements in Embedded GlassFish to enable monitoring and access it via JMX (it was completely broken before):
probe-provider-class-namesMANIFEST elements from dependencies, using gmaven plugin script at build time. It references all probes that should be activatedEmbedded GlassFish requires running with flashlight-agent on command line with -javaagent:flashlight-agent.jar on newer Java versions as it doesn't contain the agent. Dynamic loading of agent is not a good practice with newer Java versions anyway.
When started with command "enable-monitoring --mbean true", metric will be available via JMX beans:
Example to start Embedded GlassFish with thread pool and http service metrics:
Or, alternatively, using the following properties in
glassfish.propertiesin the current directory:And command:
Then in VisualVM (with MBeans extension), in the
amxnode:If you don't see the
amxnode, you need to execute thebootAMXoperation from VisualVM first (the added test demonstrates how to do that in code):