diff options
Diffstat (limited to 'pkg/sentry/state/state_metadata.go')
-rw-r--r-- | pkg/sentry/state/state_metadata.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/pkg/sentry/state/state_metadata.go b/pkg/sentry/state/state_metadata.go index ac374f428..b6d3dbcb4 100644 --- a/pkg/sentry/state/state_metadata.go +++ b/pkg/sentry/state/state_metadata.go @@ -17,13 +17,29 @@ package state import ( "fmt" "time" + + "gvisor.googlesource.com/gvisor/pkg/log" ) // The save metadata keys for timestamp. const ( + cpuUsage = "cpu_usage" metadataTimestamp = "timestamp" ) func addSaveMetadata(m map[string]string) { + t, err := cpuTime() + if err != nil { + log.Warningf("Error getting cpu time: %v", err) + } + if previousMetadata != nil { + p, err := time.ParseDuration(previousMetadata[cpuUsage]) + if err != nil { + log.Warningf("Error parsing previous runs' cpu time: %v", err) + } + t += p + } + m[cpuUsage] = t.String() + m[metadataTimestamp] = fmt.Sprintf("%v", time.Now()) } |