-
Notifications
You must be signed in to change notification settings - Fork 980
Simplify & improve OS completeName determination #11205
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
Simplify & improve OS completeName determination #11205
Conversation
08a0106 to
12be99f
Compare
1b73295 to
0917051
Compare
|
Any input from Mr @ketan here would also be appreciated :-) |
|
I remember seeing this library, but was not as evolved/matured at the time. The reason OperatingSystem.java exists in its current shape and form is to ensure that it always returns some "sensible" OS name and prevents startup failure. As long as you're able to prevent that startup failure, and checks most popular linux distros, go for it. |
|
Also, I've not seen the code — but I'd make sure to "cache" the value, so as to not evaluate the OS version on every method invocation, mostly to avoid any expensive shelling out or file reading this library might be doing under the hood. |
|
Thanks - yeah it caches the value. I'll double check the behaviour if the library can't read the value for some reason for a given distro/OS. (edit: added a fallback) |
arvindsv
left a comment
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.
Looks good to me. The SystemInfoTest is the one I was worried about -- as not being future proof, and whether we needed such a strict regex to verify it. But, it's unlikely to change too quickly. Should be ok.
Also, TIL about !! used in build.gradle (gradle doc)
Probably would be better to use the more descriptive version than the magic. (edit: fixed) The OSHI library depends on slf4j APi 2.x and it causes an implicit upgrade where which has some other problems I haven't been able to workaround yet with respect to the way we use classloaders within the agent and launcher. Their usage should still work with SLF4J 1.7.x as far as I can tell since it is largely API compatible. |
0917051 to
f8e38d2
Compare
…hi library Replace with much more modern library which we can also use for other purposes, with much better cross-platform support, and without relying on bizarre process forking to determine details.
f8e38d2 to
e20ecae
Compare
This change replaces the Python+direct file reading hack for determining a "complete" OS family names with a more modern cross-platform library (oshi) that does the same. The library has ability to use native code to get a LOT more information out from the underlying OS than is being used here.
The hack was introduced in #2421 despite some of the initial objections (as to shelling out with Python, here), reverted, and then reintroduced in #2608 eventually. The attempt to shell out to Python happens regardless of OS, and I'm not sure it does any better than reading the name from
/etc/os-releaseanyway.This change also
agentlib, to avoid dependencies propagating everywhere. Only the agent needs this logic.Some examples (before
-->after)Basically the same (linuxes)
-->Alpine Linux 3.17.1-->Ubuntu 22.04.1 LTS (Jammy Jellyfish)-->CentOS Stream 9-->Debian GNU/Linux 11 (bullseye)-->Windows 11Enhanced (non-linuxes)
-->macOS 13.1 (Ventura)-->Windows Server 2022 (Datacenter)It also adds support for many others, so is far is less opinionated than before.
Task list
Linux,GNU/Linux,Apple,Microsoftetc)