Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure cache miss logging should be displayed the right number of times in concurrent setting #2391

Merged
merged 1 commit into from
Feb 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions aws/rust-runtime/aws-credential-types/src/cache/lazy_caching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,23 @@ impl ProvideCachedCredentials for LazyCredentialsCache {
.buffer_time
.mul_f64((self.buffer_time_jitter_fraction)());

// Logging for cache miss should be emitted here as opposed to after the call to
// `cache.get_or_load` above. In the case of multiple threads concurrently executing
// `cache.get_or_load`, logging inside `cache.get_or_load` ensures that it is emitted
// only once for the first thread that succeeds in populating a cache value.
info!(
"credentials cache miss occurred; added new AWS credentials (took {:?})",
start_time.elapsed()
);

Ok((credentials, expiry + jitter))
}
// Only instrument the the actual load future so that no span
// is opened if the cache decides not to execute it.
.instrument(span)
})
.await;
info!(
"credentials cache miss occurred; retrieved new AWS credentials (took {:?})",
start_time.elapsed()
);
debug!("loaded credentials");
result
}
})
Expand Down