cmd/swarm/swarm-smoke: use ResettingTimer instead of Counters for times (#18479)

This commit is contained in:
holisticode 2019-01-18 12:14:06 -05:00 committed by Anton Evangelatov
parent a0b0db6305
commit 560957799a
1 changed files with 2 additions and 5 deletions

View File

@ -86,9 +86,8 @@ func cliUploadAndSync(c *cli.Context) error {
func uploadAndSync(c *cli.Context) error { func uploadAndSync(c *cli.Context) error {
defer func(now time.Time) { defer func(now time.Time) {
totalTime := time.Since(now) totalTime := time.Since(now)
log.Info("total time", "time", totalTime, "kb", filesize) 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()) }(time.Now())
generateEndpoints(scheme, cluster, appName, from, to) generateEndpoints(scheme, cluster, appName, from, to)
@ -103,7 +102,7 @@ func uploadAndSync(c *cli.Context) error {
log.Error(err.Error()) log.Error(err.Error())
return err 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)) fhash, err := digest(bytes.NewReader(randomBytes))
if err != nil { if err != nil {
@ -164,8 +163,6 @@ func fetch(hash string, endpoint string, original []byte, ruid string) error {
ctx, sp := spancontext.StartSpan(context.Background(), "upload-and-sync.fetch") ctx, sp := spancontext.StartSpan(context.Background(), "upload-and-sync.fetch")
defer sp.Finish() defer sp.Finish()
log.Trace("sleeping", "ruid", ruid)
time.Sleep(3 * time.Second)
log.Trace("http get request", "ruid", ruid, "api", endpoint, "hash", hash) log.Trace("http get request", "ruid", ruid, "api", endpoint, "hash", hash)
var tn time.Time var tn time.Time