*: drop use of humanize.Time() in favour of time.Duration.String()

humanize.Time() drops precision resulting in some events reporting they took
"now" time to complete. Using time.Duration.String() results in accurate
duration being reported.

Fixes #13905
This commit is contained in:
Donal Hunt 2022-04-07 22:53:58 +01:00
parent 3dce38085d
commit 4c8ef011e0
2 changed files with 3 additions and 3 deletions

View File

@ -65,7 +65,7 @@ func SaveWithVersion(ctx context.Context, lg *zap.Logger, cfg clientv3.Config, d
}
lg.Info("created temporary db file", zap.String("path", partpath))
now := time.Now()
start := time.Now()
resp, err := cli.SnapshotWithVersion(ctx)
if err != nil {
return resp.Version, err
@ -89,7 +89,7 @@ func SaveWithVersion(ctx context.Context, lg *zap.Logger, cfg clientv3.Config, d
lg.Info("fetched snapshot",
zap.String("endpoint", cfg.Endpoints[0]),
zap.String("size", humanize.Bytes(uint64(size))),
zap.String("took", humanize.Time(now)),
zap.String("took", time.Since(start).String()),
zap.String("etcd-version", version),
)

View File

@ -184,7 +184,7 @@ func (ms *maintenanceServer) Snapshot(sr *pb.SnapshotRequest, srv pb.Maintenance
ms.lg.Info("successfully sent database snapshot to client",
zap.Int64("total-bytes", total),
zap.String("size", size),
zap.String("took", humanize.Time(start)),
zap.String("took", time.Since(start).String()),
zap.String("storage-version", storageVersion),
)
return nil