From e215462518642032eb4fb9c8fde0eb82ffc6fb44 Mon Sep 17 00:00:00 2001 From: ashmrtn Date: Fri, 17 Feb 2023 22:25:05 -0800 Subject: [PATCH] Add log messages about metadata saved/used (#2551) ## Description Record the number of entries in the saved metadata. This could help catch odd situations like not finding anything to backup. ## Does this PR need a docs update or release note? - [ ] :white_check_mark: Yes, it's included - [ ] :clock1: Yes, but in a later PR - [x] :no_entry: No ## Type of change - [ ] :sunflower: Feature - [ ] :bug: Bugfix - [ ] :world_map: Documentation - [ ] :robot: Test - [ ] :computer: CI/Deployment - [x] :broom: Tech Debt/Cleanup ## Issue(s) * #2550 ## Test Plan - [x] :muscle: Manual - [ ] :zap: Unit test - [ ] :green_heart: E2E --- .../connector/exchange/service_iterators.go | 10 ++++++++ .../connector/onedrive/collections.go | 23 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/internal/connector/exchange/service_iterators.go b/src/internal/connector/exchange/service_iterators.go index 49a167437..1ee6636fe 100644 --- a/src/internal/connector/exchange/service_iterators.go +++ b/src/internal/connector/exchange/service_iterators.go @@ -50,6 +50,11 @@ func filterContainersAndFillCollections( tombstones = makeTombstones(dps) ) + logger.Ctx(ctx).Infow( + "filling collections", + "metadata_count", + len(dps)) + // TODO(rkeepers): this should be passed in from the caller, probably // as an interface that satisfies the NewCollection requirements. // But this will work for the short term. @@ -185,6 +190,11 @@ func filterContainersAndFillCollections( graph.NewMetadataEntry(graph.PreviousPathFileName, currPaths), } + logger.Ctx(ctx).Infow( + "adding metadata collection entries", + "num_paths_entries", len(currPaths), + "num_deltas_entries", len(deltaURLs)) + if len(deltaURLs) > 0 { entries = append(entries, graph.NewMetadataEntry(graph.DeltaURLsFileName, deltaURLs)) } diff --git a/src/internal/connector/onedrive/collections.go b/src/internal/connector/onedrive/collections.go index 749e865a8..f770dbbfe 100644 --- a/src/internal/connector/onedrive/collections.go +++ b/src/internal/connector/onedrive/collections.go @@ -295,6 +295,18 @@ func (c *Collections) Get( prevDelta := prevDeltas[driveID] oldPaths := oldPathsByDriveID[driveID] + numOldDelta := 0 + if len(prevDelta) > 0 { + numOldDelta++ + } + + logger.Ctx(ctx).Infow( + "previous metadata for drive", + "num_paths_entries", + len(oldPaths), + "num_deltas_entries", + numOldDelta) + delta, paths, excluded, err := collectItems( ctx, c.itemPagerFunc( @@ -312,6 +324,9 @@ func (c *Collections) Get( return nil, nil, err } + // Used for logging below. + numDeltas := 0 + // It's alright to have an empty folders map (i.e. no folders found) but not // an empty delta token. This is because when deserializing the metadata we // remove entries for which there is no corresponding delta token/folder. If @@ -319,6 +334,7 @@ func (c *Collections) Get( // for collections when not actually getting delta results. if len(delta.URL) > 0 { deltaURLs[driveID] = delta.URL + numDeltas++ } // Avoid the edge case where there's no paths but we do have a valid delta @@ -329,6 +345,13 @@ func (c *Collections) Get( maps.Copy(folderPaths[driveID], paths) maps.Copy(excludedItems, excluded) + + logger.Ctx(ctx).Infow( + "persisted metadata for drive", + "num_paths_entries", + len(paths), + "num_deltas_entries", + numDeltas) } observe.Message(ctx, observe.Safe(fmt.Sprintf("Discovered %d items to backup", c.NumItems)))