-
Notifications
You must be signed in to change notification settings - Fork 20.6k
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
metrics: replace gosigar with gopsutil #21041
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0ad0143
replace gosigar with gopsutil
renaynay 18065c4
removed check for whether GOOS is openbsd
renaynay 490fdbd
removed accidental import of runtime
renaynay d3179fa
potential fix for difference in units between gosig and gopsutil
renaynay 1474c48
fixed lint error
renaynay 9d51ba1
remove multiplication factor
renaynay f11d4d5
uses cpu.ClocksPerSec as the multiplication factor
renaynay 062fec8
changed dependency from shirou to renaynay (#20)
renaynay d64259a
updated dep
renaynay a0bda32
switching back from using renaynay fork to using upstream as PRs were…
renaynay cf6f081
removed empty line
renaynay a949888
optimized imports
renaynay bdda98d
tidied go mod
renaynay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
According to the documentation,
So you need to make sure that the units are the same as those returned by gosigar. I wanted to check the documentation and their website seems to be down. I suggest you compare both outputs.
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.
No they are not the same units.
Gosigar
uses a unit that is 128*(1 jiffy)I just pushed a potential fix here: 397b150
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.
Where does the 128 come from? Could yo upoint me to the gosigar code? I don't see any processing made by gosigar
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.
The code seems to contradict the documentation and indeed return times in seconds (in float, though 😞 )
In any case, it is unlikely that the 128 * jiffies is the same on all platforms. That's not looking too good if we can't get this to work with seconds☹️
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 find it super odd if they returned anything that percentage or millisecond. That's the expectation .If they returned different on different platforms, nobody would use them. I think something's wrong with our assessment above
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.
@renaynay I created this test program and ran it on Linux like this:
I do not find a difference of 128 but of 100 between the two. So if anything else, it proves that the 128 is platform-dependent. I'd be curious to find out what the output is when you run the same command on darwin, though.
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.
@karalabe They do return "CPU ticks" which is neither a percentage nor a millisecond, and they are platform dependent:
parseCPUStats
, defined in https://github.com/elastic/gosigar/blob/master/sigar_linux.go#L95, parses a line taken from/proc/stat
which returns values in "cpu ticks" and this is platform-dependent.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.
Which makes me think: we can calculate the percentages. This would be accurate, whatever the unit is that is returned as they are divided by one another.