From ffbd9c1ead17cdc2fcd605f9049d3a7336785447 Mon Sep 17 00:00:00 2001 From: ahrav Date: Tue, 21 Mar 2023 09:14:58 -0700 Subject: [PATCH] [chore] - log enumeration duration (#1187) * log enumeration duration. * use defer to print enumeration duration stat. * remove temp var. --- pkg/sources/gcs/gcs_manager.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/sources/gcs/gcs_manager.go b/pkg/sources/gcs/gcs_manager.go index 3fb58a8e..4758e2e3 100644 --- a/pkg/sources/gcs/gcs_manager.go +++ b/pkg/sources/gcs/gcs_manager.go @@ -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 }