-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
why in this place use System.exit(1)? #745
Comments
What else would you expect to happen if you run it with illegal command line parameters? |
I mean if use System.exit(1),Will using this cause the process of the application that the user mounts the jmx-exporter agent to also exit? |
Yes. If you start the application with an illegal command line, the application exits immediately. |
So I think this place is not very user friendly, is there any way to optimize it here |
@zhic0223 not sure what you're trying to accomplish. If you define your application to use the agent and the agent is misconfigured, allowing the application to run without the agent doesn't make sense to me. |
When the agent of jmx-exporter is mounted, if the client's application is forcibly exited simply because the parameters of vm options do not conform to the specifications of jmx, I think this is unreasonable. You can only exit the agent, not the Also opted out of the client's app. |
I think this part can be optimized to remind the user that the vm options parameter configured when accessing the agent is incorrect, and tell him the correct configuration method, which is more secure. You can't cut off a person's head just because he has a cold. |
@zhic0223 I disagree. Allowing the application to run with a misconfigured agent will most likely result in more work on the end user to debug the issue and possibly more GitHub issues... "We installed and configured the agent and the application is running, but we can't access the JMX metrics" |
@dhoard There is a scenario that the customer's online application needs to monitor and observe the indicators of jvm for some reason, and then the customer mounts jmx, but his online application is not allowed to hang up for a long time. Then if the customer's vm options parameter is wrongly written, will the customer's online application always fail to start? What if that app has a lot of people online? If the customer's application is directly exited by jmx, the customer will never use jmx again? |
@zhic0223 Thanks for the use case clarification. The agent is written assuming it will be defined as part of the JVM arguments and configured correctly. In my opinion/experience, this is the most common use-case scenario. The code would need to be changed to support dynamic attachment correctly. (Failure of the agent doesn't cause the application to exit.) Keep in mind that attaching an agent dynamically to a running JVM requires the application to be coded to dynamically load the agent. @fstab is dynamic loading with bad configuration a scenario the agent is expected to correctly handle? EDIT: updated question |
To support correctly support dynamic agent loading (prevent misconfiguration from exiting the application when using the agent dynamically) the
|
@dhoard thanks a lot for looking into this. I agree the agent is not written with dynamic attachment in mind. There are some other issues as well, like the agent does not detach cleanly as some classes will still be referenced after detaching the agent (see prometheus/client_java#809). The recommended usage is either to attach the agent at startup and leave it attached, or to run |
You're welcome!I hope there are more scenarios to be tested and perfected here. |
Dynamic attachment is not supported/working as designed. Closing as resolved. |
why in this place use System.exit(1)? Can I rm it?
The text was updated successfully, but these errors were encountered: