From 92b404b11cd0dad2c64cba2c305519eb7f746970 Mon Sep 17 00:00:00 2001 From: Fabio Barone Date: Fri, 18 Jan 2019 09:45:13 -0500 Subject: [PATCH 1/2] cmd/swarm/swarm-smoke: use ResettingTimer instead of Counters for times --- cmd/swarm/swarm-smoke/upload_and_sync.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cmd/swarm/swarm-smoke/upload_and_sync.go b/cmd/swarm/swarm-smoke/upload_and_sync.go index 728975c36bd3..a3a972191124 100644 --- a/cmd/swarm/swarm-smoke/upload_and_sync.go +++ b/cmd/swarm/swarm-smoke/upload_and_sync.go @@ -86,9 +86,8 @@ func cliUploadAndSync(c *cli.Context) error { func uploadAndSync(c *cli.Context) error { defer func(now time.Time) { totalTime := time.Since(now) - log.Info("total time", "time", totalTime, "kb", filesize) - metrics.GetOrRegisterCounter("upload-and-sync.total-time", nil).Inc(int64(totalTime)) + metrics.GetOrRegisterResettingTimer("upload-and-sync.total-time", nil).Update(totalTime) }(time.Now()) generateEndpoints(scheme, cluster, appName, from, to) @@ -103,7 +102,7 @@ func uploadAndSync(c *cli.Context) error { log.Error(err.Error()) return err } - metrics.GetOrRegisterCounter("upload-and-sync.upload-time", nil).Inc(int64(time.Since(t1))) + metrics.GetOrRegisterResettingTimer("upload-and-sync.upload-time", nil).UpdateSince(t1) fhash, err := digest(bytes.NewReader(randomBytes)) if err != nil { From b0f150caf5c0da48a626457473a6fc1493c3f700 Mon Sep 17 00:00:00 2001 From: Fabio Barone Date: Fri, 18 Jan 2019 11:43:21 -0500 Subject: [PATCH 2/2] cmd/swarm/swarm-smoke: remove sleeping from fetch --- cmd/swarm/swarm-smoke/upload_and_sync.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmd/swarm/swarm-smoke/upload_and_sync.go b/cmd/swarm/swarm-smoke/upload_and_sync.go index a3a972191124..7babc80044bb 100644 --- a/cmd/swarm/swarm-smoke/upload_and_sync.go +++ b/cmd/swarm/swarm-smoke/upload_and_sync.go @@ -163,8 +163,6 @@ func fetch(hash string, endpoint string, original []byte, ruid string) error { ctx, sp := spancontext.StartSpan(context.Background(), "upload-and-sync.fetch") defer sp.Finish() - log.Trace("sleeping", "ruid", ruid) - time.Sleep(3 * time.Second) log.Trace("http get request", "ruid", ruid, "api", endpoint, "hash", hash) var tn time.Time