mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-21 22:36:39 +00:00
Verified the TODO comments and make durations be in seconds.
This commit is contained in:
@@ -101,7 +101,7 @@ export function formatDataType(field, referenceTimestampStr = null) {
|
||||
};
|
||||
},
|
||||
duration(durationString) {
|
||||
const humanizedDuration = moment.duration(parseInt(durationString, 10)).humanize();
|
||||
const humanizedDuration = moment.duration(Number(durationString), 'seconds').humanize();
|
||||
return {
|
||||
value: humanizedDuration,
|
||||
title: humanizedDuration,
|
||||
|
||||
@@ -425,14 +425,12 @@ func (c *container) GetNode() report.Node {
|
||||
controls := c.controlsMap()
|
||||
|
||||
if !c.container.State.Paused && c.container.State.Running {
|
||||
// TODO: Use mtime.Now() only as a fallback from Time Travel
|
||||
// timestamp here to get accurate durations when time travelling.
|
||||
uptimeMs := mtime.Now().Sub(c.container.State.StartedAt) / time.Millisecond
|
||||
uptimeSeconds := int(mtime.Now().Sub(c.container.State.StartedAt) / time.Second)
|
||||
networkMode := ""
|
||||
if c.container.HostConfig != nil {
|
||||
networkMode = c.container.HostConfig.NetworkMode
|
||||
}
|
||||
latest[ContainerUptime] = strconv.Itoa(int(uptimeMs))
|
||||
latest[ContainerUptime] = strconv.Itoa(uptimeSeconds)
|
||||
latest[ContainerRestartCount] = strconv.Itoa(c.container.RestartCount)
|
||||
latest[ContainerNetworkMode] = networkMode
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ func TestContainer(t *testing.T) {
|
||||
|
||||
// Now see if we go them
|
||||
{
|
||||
uptimeMs := int(now.Sub(startTime) / time.Millisecond)
|
||||
uptimeSeconds := int(now.Sub(startTime) / time.Second)
|
||||
controls := map[string]report.NodeControlData{
|
||||
docker.UnpauseContainer: {Dead: true},
|
||||
docker.RestartContainer: {Dead: false},
|
||||
@@ -80,7 +80,7 @@ func TestContainer(t *testing.T) {
|
||||
"docker_label_foo2": "bar2",
|
||||
"docker_container_state": "running",
|
||||
"docker_container_state_human": c.Container().State.String(),
|
||||
"docker_container_uptime": strconv.Itoa(uptimeMs),
|
||||
"docker_container_uptime": strconv.Itoa(uptimeSeconds),
|
||||
"docker_env_FOO": "secret-bar",
|
||||
}).WithLatestControls(
|
||||
controls,
|
||||
|
||||
@@ -103,7 +103,6 @@ func (r *Reporter) Report() (report.Report, error) {
|
||||
localCIDRs = append(localCIDRs, localNet.String())
|
||||
}
|
||||
|
||||
// TODO: Make sure uptime is accurate also when time travelling.
|
||||
uptime, err := GetUptime()
|
||||
if err != nil {
|
||||
return rep, err
|
||||
@@ -132,7 +131,7 @@ func (r *Reporter) Report() (report.Report, error) {
|
||||
HostName: r.hostName,
|
||||
OS: runtime.GOOS,
|
||||
KernelVersion: kernel,
|
||||
Uptime: strconv.Itoa(int(uptime / time.Millisecond)),
|
||||
Uptime: strconv.Itoa(int(uptime / time.Second)), // uptime in seconds
|
||||
ScopeVersion: r.version,
|
||||
}).
|
||||
WithSets(report.MakeSets().
|
||||
|
||||
@@ -25,7 +25,7 @@ func TestReporter(t *testing.T) {
|
||||
host.CPUUsage: report.MakeSingletonMetric(timestamp, 30.0).WithMax(100.0),
|
||||
host.MemoryUsage: report.MakeSingletonMetric(timestamp, 60.0).WithMax(100.0),
|
||||
}
|
||||
uptime = "3600000" // one hour
|
||||
uptime = "3600" // one hour
|
||||
kernel = "release version"
|
||||
_, ipnet, _ = net.ParseCIDR(network)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user