feat(storage): add resource span attributes for ACO ( App Centric Observability ) for async client#16151
feat(storage): add resource span attributes for ACO ( App Centric Observability ) for async client#16151bajajneha27 wants to merge 15 commits into
Conversation
…ervability ) for async client
There was a problem hiding this comment.
Code Review
This pull request introduces a BucketMetadataCache to cache bucket metadata (ID and location) and uses it to enrich OpenTelemetry spans with destination resource attributes in both TracingConnection and AsyncConnectionTracing. When metadata is not cached, a background fetch is triggered. The review feedback highlights several important issues: a critical data race on bg_tasks_ in TracingConnection::MaybeTriggerBackgroundFetch due to a lack of mutex protection during push_back, potential undefined behavior in BucketMetadataCache::Put if max_size is initialized to 0, unnormalized bucket names on permission denied errors in TracingConnection, and performance concerns regarding the expensive creation of a new StorageConnection on every background fetch in AsyncConnectionTracing.
| cache().EndFetch(bucket_name); | ||
| }); | ||
|
|
||
| bg_tasks_.push_back(std::move(f)); |
There was a problem hiding this comment.
There is a data race on bg_tasks_ because bg_tasks_.push_back is called without holding the mu_ mutex. Since MaybeTriggerBackgroundFetch can be called concurrently from multiple threads, and CleanupCompletedTasks also modifies bg_tasks_ under mu_, this concurrent modification of std::vector leads to undefined behavior and potential crashes. Protect the push_back call with mu_ just like in AsyncConnectionTracing.
std::unique_lock<std::mutex> lk(mu_);
bg_tasks_.push_back(std::move(f));| } else if (result.status().code() == StatusCode::kPermissionDenied) { | ||
| cache().Put(bucket_name, {"projects/_/buckets/" + bucket_name, "global"}); | ||
| } |
There was a problem hiding this comment.
To be consistent with AsyncConnectionTracing and to handle any potentially unnormalized bucket names safely, normalize the bucket_name before constructing the fallback resource ID on kPermissionDenied errors.
} else if (result.status().code() == StatusCode::kPermissionDenied) {
auto const normalized = BucketMetadataCache::NormalizeBucketName(bucket_name);
cache().Put(bucket_name, {"projects/_/buckets/" + normalized, "global"});
}
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #16151 +/- ##
==========================================
- Coverage 92.20% 92.18% -0.02%
==========================================
Files 2264 2267 +3
Lines 208864 209376 +512
==========================================
+ Hits 192579 193023 +444
- Misses 16285 16353 +68 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
No description provided.