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?

- [ ]  Yes, it's included
- [ ] 🕐 Yes, but in a later PR
- [x]  No 

## Type of change

- [ ] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Test
- [ ] 💻 CI/Deployment
- [x] 🧹 Tech Debt/Cleanup

## Issue(s)

* #2550

## Test Plan

- [x] 💪 Manual
- [ ]  Unit test
- [ ] 💚 E2E
This commit is contained in:
ashmrtn 2023-02-17 22:25:05 -08:00 committed by GitHub
parent bf12428738
commit e215462518
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 0 deletions

View File

@ -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))
}

View File

@ -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)))