Minor url cache logging & counting improvements (#4801)

<!-- PR description-->

1. Move cache miss logs to debug, as it can be chatty sometimes. We will leverage the end of operation `URLCacheMiss` counter to get this information instead.
2. Counter renaming. 
---

#### 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

<!--- Please check the type of change your PR introduces: --->
- [ ] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Supportability/Tests
- [ ] 💻 CI/Deployment
- [x] 🧹 Tech Debt/Cleanup

#### Issue(s)

<!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. -->
* #<issue>

#### Test Plan

<!-- How will this be tested prior to merging.-->
- [x] 💪 Manual
- [ ]  Unit test
- [ ] 💚 E2E
This commit is contained in:
Abhishek Pandey 2023-12-04 18:18:13 -08:00 committed by GitHub
parent 7ef5a33edf
commit 3ee1a8d166
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 9 deletions

View File

@ -379,11 +379,10 @@ func downloadContent(
return content, nil return content, nil
} }
// Consider cache errors(including deleted items) as cache misses. This is // Consider cache errors(including deleted items) as cache misses.
// to preserve existing behavior. Fallback to refetching the item using the // Fallback to refetching the item using the graph API.
// API. logger.CtxErr(ctx, err).Debug("url cache miss: refetching from API")
logger.CtxErr(ctx, err).Info("url cache miss: refetching from API") counter.Inc(count.URLCacheMiss)
counter.Inc(count.ItemDownloadURLRefetch)
di, err := iaag.GetItem(ctx, driveID, ptr.Val(item.GetId())) di, err := iaag.GetItem(ctx, driveID, ptr.Val(item.GetId()))
if err != nil { if err != nil {
@ -423,7 +422,7 @@ func readItemContents(
rc, err := downloadFile(ctx, iaag, props.downloadURL) rc, err := downloadFile(ctx, iaag, props.downloadURL)
if graph.IsErrUnauthorizedOrBadToken(err) { if graph.IsErrUnauthorizedOrBadToken(err) {
logger.CtxErr(ctx, err).Info("stale item in cache") logger.CtxErr(ctx, err).Debug("stale item in cache")
} }
if err != nil { if err != nil {

View File

@ -35,7 +35,7 @@ type itemProps struct {
var _ getItemPropertyer = &urlCache{} var _ getItemPropertyer = &urlCache{}
// urlCache caches download URLs for drive items // urlCache caches download URLs for drive file items
type urlCache struct { type urlCache struct {
driveID string driveID string
prevDelta string prevDelta string
@ -207,7 +207,7 @@ func (uc *urlCache) readCache(
props, ok := uc.idToProps[itemID] props, ok := uc.idToProps[itemID]
if !ok { if !ok {
uc.counter.Inc(count.URLCacheMiss) uc.counter.Inc(count.URLCacheItemNotFound)
return itemProps{}, clues.NewWC(ctx, "item not found in cache") return itemProps{}, clues.NewWC(ctx, "item not found in cache")
} }

View File

@ -38,7 +38,6 @@ const (
DriveTombstones Key = "drive-tombstones" DriveTombstones Key = "drive-tombstones"
Files Key = "files" Files Key = "files"
Folders Key = "folders" Folders Key = "folders"
ItemDownloadURLRefetch Key = "item-download-url-refetch"
ItemsAdded Key = "items-added" ItemsAdded Key = "items-added"
ItemsRemoved Key = "items-removed" ItemsRemoved Key = "items-removed"
LazyDeletedInFlight Key = "lazy-deleted-in-flight" LazyDeletedInFlight Key = "lazy-deleted-in-flight"
@ -68,6 +67,7 @@ const (
TotalContainersSkipped Key = "total-containers-skipped" TotalContainersSkipped Key = "total-containers-skipped"
URLCacheMiss Key = "url-cache-miss" URLCacheMiss Key = "url-cache-miss"
URLCacheRefresh Key = "url-cache-refresh" URLCacheRefresh Key = "url-cache-refresh"
URLCacheItemNotFound Key = "url-cache-item-not-found"
) )
// Total___Processed counts are used to track raw processing numbers // Total___Processed counts are used to track raw processing numbers