-
Notifications
You must be signed in to change notification settings - Fork 216
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
feat: add kernelVersion to telemetry traces #1094
base: main
Are you sure you want to change the base?
feat: add kernelVersion to telemetry traces #1094
Conversation
@microsoft-github-policy-service agree |
b9a34f3
to
bc6557b
Compare
@Anirudh2112 the infinite recursion is still present, |
70fd88e
to
ad29b29
Compare
Apologies for the oversight regarding the infinite recursion. In the recent changes, I’ve addressed this by:
|
Signed-off-by: Anirudh <[email protected]>
503c6d6
to
f514bbb
Compare
There's no particular reason why this KernelVersion platform detection has to be done at compile time. It complicates testing, as the function is redefined by build tags, so the only way to avoid invoking commands on the host is to have a throwaway func var to assign KernelVersion to. It's completely reasonable to think that there's other information that we might want to grab from the host eventually, so this really should reside in a client of some kind. This patch adds such a client and makes KernelVersion a method of it. This method uses runtime.GOOS to decide at runtime which command will be invoked based on the platform found. This opens the door for using an interface to mock this method more cleanly in tests that desire to do so. Those tests have been updated. Finally, the global `KernelVersion` func has been removed in favor of instantiating one of these HostInfoClients instead (the surface area of `KernelVersion` was very small, so the refactor was trivial).
@Anirudh2112 I had a few suggestions, mostly around the use of the global var to mock the Looking at the patch closer though, I can see what you had to work with, and a lot of it was pre-existing. I went ahead and made the changes I suggested to save some back-and-forth. The commit is on traymond/kernelversion-traces. Assuming the typical "triangular workflow," you should be able to fetch it from your |
@timraymond I've merged your changes from the traymond/kernelversion-traces branch. I appreciate the improvements made to handle platform detection at runtime and the cleaner approach using the HostInfoClient. I've reviewed the changes and understand this removes the need for compile-time platform detection while making the code more testable. Please let me know if there's anything else needed. |
Description
This pull request adds the kernelVersion property to telemetry traces in the TrackTrace method. This enhancement allows pinpointing the specific kernel version responsible for producing logs.
To achieve this:
Introduced a kernelVersionFunc variable to enable easier mocking during tests.
Updated the TrackTrace method to include kernelVersion in telemetry traces.
Added a test (TestTrackTraceIncludesKernelVersion) to verify the inclusion of kernelVersion in trace properties.
Related Issue
This pull request addresses the issue:
#1071
Checklist
I have read the contributing documentation
I signed and signed-off the commits (git commit -S -s ...).
I have tested the changes locally.
I have followed the project's style guidelines.
I have added tests.
Screenshots (if applicable) or Testing Completed
Test Output
The following test passes successfully: