Skip to content
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

Closed
zhic0223 opened this issue Nov 3, 2022 · 15 comments
Closed

why in this place use System.exit(1)? #745

zhic0223 opened this issue Nov 3, 2022 · 15 comments

Comments

@zhic0223
Copy link

zhic0223 commented Nov 3, 2022

image

why in this place use System.exit(1)? Can I rm it?

@zhic0223
Copy link
Author

zhic0223 commented Nov 3, 2022

@brian-brazil

@fstab
Copy link
Member

fstab commented Nov 3, 2022

What else would you expect to happen if you run it with illegal command line parameters?

@zhic0223
Copy link
Author

zhic0223 commented Nov 3, 2022

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?

@fstab
Copy link
Member

fstab commented Nov 3, 2022

Yes. If you start the application with an illegal command line, the application exits immediately.

@zhic0223
Copy link
Author

zhic0223 commented Nov 3, 2022

So I think this place is not very user friendly, is there any way to optimize it here

@dhoard
Copy link
Collaborator

dhoard commented Nov 6, 2022

@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.

@zhic0223
Copy link
Author

zhic0223 commented Nov 8, 2022

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.

@zhic0223
Copy link
Author

zhic0223 commented Nov 8, 2022

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.

@dhoard
Copy link
Collaborator

dhoard commented Nov 16, 2022

@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"

@zhic0223
Copy link
Author

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?

@dhoard
Copy link
Collaborator

dhoard commented Nov 17, 2022

@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

@dhoard
Copy link
Collaborator

dhoard commented Nov 17, 2022

To support correctly support dynamic agent loading (prevent misconfiguration from exiting the application when using the agent dynamically) theJmxCollector code would also need to be changed.

@fstab
Copy link
Member

fstab commented Nov 17, 2022

@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 jmx_exporter_httpserver in standalone mode and scrape JMX beans remotely via the network.

@zhic0223
Copy link
Author

@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

You're welcome!I hope there are more scenarios to be tested and perfected here.

@dhoard
Copy link
Collaborator

dhoard commented Apr 14, 2023

Dynamic attachment is not supported/working as designed.

Closing as resolved.

@dhoard dhoard closed this as completed May 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants