Created
November 30, 2022 01:01
-
-
Save jsturtevant/a7da98d6139b133eeb72576ef362fd95 to your computer and use it in GitHub Desktop.
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
func windowsCpuAndMemoryStats(stats *types.Metric) (*runtime.WindowsContainerStats, error) { | |
var cs runtime.WindowsContainerStats | |
if stats != nil { | |
s, err := typeurl.UnmarshalAny(stats.Data) | |
if err != nil { | |
return nil, fmt.Errorf("failed to extract container metrics: %w", err) | |
} | |
wstats := s.(*wstats.Statistics).GetWindows() | |
if wstats == nil { | |
return nil, fmt.Errorf("windows stats is empty") | |
} | |
if wstats.Processor != nil { | |
cs.Cpu = &runtime.WindowsCpuUsage{ | |
Timestamp: wstats.Timestamp.UnixNano(), | |
UsageCoreNanoSeconds: &runtime.UInt64Value{Value: wstats.Processor.TotalRuntimeNS}, | |
} | |
} | |
if wstats.Memory != nil { | |
cs.Memory = &runtime.WindowsMemoryUsage{ | |
Timestamp: wstats.Timestamp.UnixNano(), | |
WorkingSetBytes: &runtime.UInt64Value{ | |
Value: wstats.Memory.MemoryUsagePrivateWorkingSetBytes, | |
}, | |
} | |
} | |
} | |
return &cs, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment