-
Notifications
You must be signed in to change notification settings - Fork 764
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
Add container.cpu.time metric #5806
base: main
Are you sure you want to change the base?
Add container.cpu.time metric #5806
Conversation
c56acb3
to
795d513
Compare
795d513
to
d946512
Compare
🎉 Good job! The coverage increased 🎉
Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=922984&view=codecoverage-tab |
@andrey-noskov FYI |
@@ -15,6 +16,7 @@ namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows; | |||
internal sealed class WindowsContainerSnapshotProvider : ISnapshotProvider | |||
{ | |||
private const double Hundred = 100.0d; | |||
private const double TicksPerSecoundDouble = TimeSpan.TicksPerSecond; |
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.
private const double TicksPerSecoundDouble = TimeSpan.TicksPerSecond; | |
private const double TicksPerSecondDouble = TimeSpan.TicksPerSecond; |
...raries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Linux/LinuxUtilizationProvider.cs
Show resolved
Hide resolved
using var jobHandle = _createJobHandleObject(); | ||
var basicAccountingInfo = jobHandle.GetBasicAccountingInfo(); | ||
|
||
yield return new(basicAccountingInfo.TotalUserTime / TicksPerSecoundDouble, [new KeyValuePair<string, object?>("cpu.mode", "user")]); |
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.
What's the difference between UserTime and KernelTime from perspective of container running in Cosmic?
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.
Not sure if I got the question right, but I don't think it is different from what you have without containers/k8s. See also https://unix.stackexchange.com/questions/87625/what-is-difference-between-user-space-and-kernel-space
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.
For Linux (cgroupv2) I see that we're going to report (correct me if I'm wrong):
cpu.mode=user
is /sys/fs/cgroup/cpu.stat
so CPU time from container related cgroup
cpu.mode=system
is /proc/stat
) so host CPU time, which is whole machine, which in fact can host hundreds of containers.
For Windows based on JOBOBJECT:
cpu.mode=user
- TotalUserTime - The total amount of user-mode execution time for all active processes associated with the job
, what's the job in this case? And what's user-mode?
cpu.mode=system
- TotalKernelTime - The total amount of kernel-mode execution time for all active processes associated with the job
, what's the job in this case? And what's kernel-mode?
Basically, I'm trying to double check what those values are representing, so tags make sense, and that they represent same thing in both OSes.
Fixes #5800
Microsoft Reviewers: Open in CodeFlow