[chore] - log enumeration duration (#1187)

* log enumeration duration.

* use defer to print enumeration duration stat.

* remove temp var.
This commit is contained in:
ahrav 2023-03-21 09:14:58 -07:00 committed by GitHub
parent 62d44f59f5
commit ffbd9c1ead
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -383,6 +383,10 @@ func (g *gcsManager) enumerate(ctx context.Context, bkts []bucket) (*attributes,
logger.V(5).Info("enumerating buckets", "numBuckets", len(bkts))
stats := newStats(len(bkts))
defer func(start time.Time) {
logger.V(5).Info("finished enumerating buckets", "duration-seconds", fmt.Sprintf("%.1f", time.Since(start).Seconds()), "num-buckets", len(bkts), "num-objects", stats.numObjects)
}(time.Now())
for _, bkt := range bkts {
bkt := bkt
g.workerPool.Go(func() error {
@ -426,7 +430,6 @@ func (g *gcsManager) enumerate(ctx context.Context, bkts []bucket) (*attributes,
_ = g.workerPool.Wait()
g.attr = stats
logger.V(5).Info("finished enumerating buckets", "num-objects", stats.numObjects, "num-buckets", stats.numBuckets)
return stats, nil
}