-
Notifications
You must be signed in to change notification settings - Fork 501
[EXPORTER] Fixes tsan warnings #3531
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
Conversation
✅ Deploy Preview for opentelemetry-cpp-api-docs canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR suppresses ThreadSanitizer warnings for callback_thread
in HttpOperation
by introducing a dedicated accessor with TSAN-ignore annotations and memory fences.
- Add
HttpOperationAccessor
withOPENTELEMETRY_SANITIZER_NO_THREAD
wrappers and memory fences aroundcallback_thread
access. - Replace direct
async_data_->callback_thread
reads/writes withHttpOperationAccessor::GetThreadId
/SetThreadId
. - Declare
HttpOperationAccessor
as afriend
in theHttpOperation
class header.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
ext/src/http/client/curl/http_operation_curl.cc | Introduces HttpOperationAccessor and replaces direct callback_thread accesses with accessor calls. |
ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h | Adds friend class HttpOperationAccessor; to grant the accessor private access to HttpOperation::AsyncData . |
Comments suppressed due to low confidence (2)
ext/src/http/client/curl/http_operation_curl.cc:53
- [nitpick] It may be helpful to add a brief comment explaining why
OPENTELEMETRY_SANITIZER_NO_THREAD
is applied here, clarifying the intent to silence TSAN warnings for this accessor.
OPENTELEMETRY_SANITIZER_NO_THREAD static std::thread::id GetThreadId(
ext/src/http/client/curl/http_operation_curl.cc:360
- Consider adding unit tests that verify
callback_thread
is correctly set, read, and reset through the accessor functions to prevent regressions in callback synchronization.
if (HttpOperationAccessor::GetThreadId(*async_data_) != std::this_thread::get_id())
{ | ||
namespace curl | ||
{ | ||
|
Copilot
AI
Jul 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider placing HttpOperationAccessor in an anonymous namespace since it’s only used within this translation unit, to avoid exporting an internal utility.
namespace | |
{ |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anonymous namespace will break the friend access.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3531 +/- ##
==========================================
- Coverage 90.03% 90.00% -0.02%
==========================================
Files 220 220
Lines 7069 7069
==========================================
- Hits 6364 6362 -2
- Misses 705 707 +2 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch.
See some questions on the ifdef logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes #3530
Changes
callback_thread
has data race inHttpOperation
. So just ignore it.For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes