-
Notifications
You must be signed in to change notification settings - Fork 521
[ETW] Fix tracer initialization order #3824
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
[ETW] Fix tracer initialization order #3824
Conversation
.vscode/settings.json
Outdated
| @@ -0,0 +1,3 @@ | |||
| { | |||
| "cmake.sourceDirectory": "/wsl.localhost/Ubuntu/home/percy/opentelemetry-cpp" | |||
| } No newline at end of file | |||
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.
seems to be incorrectly checked in?
| * @brief Provider Handle | ||
| */ | ||
| ETWProvider::Handle &provHandle; | ||
| //change made in pr |
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.
nit -this line seems unnecessary.
|
|
||
| std::atomic<bool> isClosed_{true}; | ||
| // Fix: Declare isClosed_ before provHandle so it initializes to true | ||
| // *before* initProvHandle() runs. |
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.
please remove all the above comments - we don't need PR change history as part of comment.
927910d to
f6b3576
Compare
| std::atomic<bool> isClosed_{true}; | ||
|
|
||
| /** | ||
| * @brief ETWProvider is a singleton that aggregates all ETW writes. |
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.
Is this line duplicated?
|
|
||
| /** | ||
| * @brief Provider Handle | ||
| */ |
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.
Move the above 3 lines comment with provHandle?
|
@beep-boopp thanks for the fix. Please also address the CI issue and comments, looks good otherwise. |
6ab7c2f to
5302f1f
Compare
I pushed a new commit, waiting for approval. The CI shows 'Awaiting Approval' since this is my first contribution, but the build should be green once approved. Ready to merge. Once again thanks for all the help |
I approved the CI. Seems more code format needed. |
5302f1f to
109d27e
Compare
Thanks for the approval! I actually just force-pushed a clearer fix (switched to a getter instead of friend class and squashed the old commits). The formatting should be solid now too, but let me know if the CI catches anything else . |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3824 +/- ##
=======================================
Coverage 89.96% 89.96%
=======================================
Files 225 225
Lines 7170 7170
=======================================
Hits 6450 6450
Misses 720 720 🚀 New features to boost your workflow:
|
marcalff
left a comment
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.
The test looks good, but I disagree with the fix in etw_tracer.h
A better solution is to remove method initProvHandle() entirely: calling a method from the constructor was a bad idea in the first place.
Thanks for the clarification , I see where you’re coming from, and I agree that calling a helper like initProvHandle() from the constructor isn’t ideal. |
7f57e9d to
18503ab
Compare
Replace the call |
+1 |
I believe my latest commit already does exactly this: I removed initProvHandle() entirely and replaced the call in the constructor with a direct call to etwProvider().open(provId, encoding), keeping the change minimal. |
|
@lalitb Thanks for the help with the updates. |
| return etwProvider().open(provId, encoding); | ||
| } | ||
|
|
||
| public: |
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.
Removed the public: declaration for the constructor ?
This breaks the build, see CI.
|
|
||
| // Order matters: isClosed_ must initialize to true BEFORE provHandle | ||
| // runs its initialization logic. | ||
| std::atomic<bool> isClosed_{true}; |
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.
There is no need to more the declaration around for isClosed_, please revert this change back to the original code.
marcalff
left a comment
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.
See build breaks in CI.
b16c146 to
0d18db0
Compare
@marcalff Thanks for the detailed review! Good catch on the missing public: modifier, I definitely missed that while cleaning up the helper function. |
|
Apologies for the extra CI noise on this PR and new commit. I noticed the Windows Bazel build failed due to an MSVC-specific namespace resolution error (C2653) in the new test case. I've updated it to use the fully qualified namespace opentelemetry::exporter::etw:: to ensure compatibility across all builders. Ready for another look whenever you have the time |
marcalff
left a comment
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 fix.
[ETW] Fix tracer initialization order (open-telemetry#3824)
Description
Fixes #3821
The
ETWTracerwas incorrectly starting in a closed state due to member initialization order.isClosed_was declared afterprovHandle, so its default initializer ({true}) was running afterprovHandle's constructor had already set it tofalse. This overwrote the correct state.I moved
isClosed_beforeprovHandleto ensure it initializes first.Testing
Added
ConstructorInitializesToOpenStatetoetw_tracer_test.cc.I added a friend declaration in the header to verify that
isClosed_is correctlyfalseimmediately after the tracer is instantiated.Type of Change
Checklist