-
Notifications
You must be signed in to change notification settings - Fork 507
[API] Make Request Context Token constructor public #3708
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
[API] Make Request Context Token constructor public #3708
Conversation
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3708 +/- ##
==========================================
- Coverage 90.01% 90.00% -0.01%
==========================================
Files 225 225
Lines 7105 7105
==========================================
- Hits 6395 6394 -1
- Misses 710 711 +1
🚀 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.
LGTM, thanks for the fix.
|
Please review. This looks good to me, but given how this touches the very core of the instrumentation API (runtime context), better be safe than sorry. |
|
Not ABI-breaking, but the change looks unnecessary and could introduce design issues by increasing visibility. If additional data needs to be associated, it can be handled externally (e.g., |
How would this work ? The whole point is to inherit form Token, to trigger custom code in the destructor, invoked when the unique_ptr gets out of scope. With a separate map, when would the map be maintained ? |
|
Note that |
Maybe I am missing something - what's the use-case of inheriting from Token. |
|
I'm specifically trying to integrate |
|
At least the destructor should be virtual then. |
|
Let's discuss the details in the next opentelemetry-cpp SIG meeting:
|
@marcalff will try to join the meeting bit late. To summarise my concern
|
|
Can we keep Token(const Context &context) : context_(context) {}as protected as well ? |
lalitb
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.
LGTM, I think there are workaround by storing guards in RuntimeContextStorage, but the change achieves better RAII pattern.
|
Instead of making it |
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.
Looks ok, with the following changes:
- The constructor of Token should be protected, not public
- The destructor of Token should be virtual
And, as the virtual destructor implies, the custom token may have its own state, it may also require a custom ==. Therefore
|
Thanks for the comments. In this case, the The Of course it would be better to see an actual implementation of a CustomToken and a CustomRuntimeContextStorage to grasp all what is needed here, I think what is missing the most is an example custom runtime context to validate we have all the missing pieces here, as well as show a template implementation to use, but we don't have that at the moment. |
Yes, you're right. Somehow I've overseen that it's not an equality operator. In this case the operator is a bit abused ;). |
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.
LGTM
[API] Make Request Context Token constructor public (open-telemetry#3708)
Fixes #3034
I'd like to implement a custom
RuntimeContextStorageand need to store some additional data in a subclass ofToken. Based on previous discussions in #3034, it seemed like people were OK with making this constructor public, so I'm doing that here.Changes
Tokenconstructor from private to protectedcontext_protected, so subclasses can access it.Tokendestructor virtualFor significant contributions please make sure you have completed the following items:
CHANGELOG.mdupdated for non-trivial changes