-
Notifications
You must be signed in to change notification settings - Fork 592
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
Add non-const overload to Ice::Request::getCurrent #497
Conversation
Contributor requirements have been met. |
This enables C++ implementations of Ice::DispatchInterceptor to modify the incoming request before passing it to the servant.
667ce13
to
e344482
Compare
This limitation doesn't exist in other languages but we didn't really intend to allow updates of this object data members. It's just that other languages lack the concept of const objects like in C++. What's your use case for modifying the current object? |
The use case is instrumentation of our application with OpenTracing. Incoming Ice calls have a SpanContext in their Inside of the servant, the implementation could optionally decide to deserialze the current SpanContext from it's With regards to your comment about not allowing the DispatchInterceptor to modify the request: Is there a problem with allowing mutable access to the Also: you own examples in cpp/test/Ice/interceptor/AMDInterceptorI.cpp explicitly modify the |
Our tests are definitely not good examples 😄 We'll discuss some more your proposal... but did you consider using per-thread implicit contexts instead of modifying the dispatch context? Your dispatch interceptor could read the This way, invocations from the servant dispatch would automatically use this context instead of having to provide the context from |
I looked at per-thread contexts briefly, but the description threw me off somewhat:
What if I get back a proxy from an Ice invocation, and then invoke a method on that proxy? Which context will be sent? I would need to experiment to find out if this would work. Also, implicit contexts are only sent if there is no explicit context. We occasionally use explicit contexts in our software, meaning those invocations could not be traced. |
The documentation should probably say "associated with" instead of "created by" that communicator. If you receive a proxy form an invocation, the implicit context associated with the proxy's communicator will be used if no explicit context is provided. The code using explicit context will need to be fixed to initialize the explicit context with the implicit context:
|
I spent some more time on this. Per-thread implicit contexts + DispatchInterceptors are actually a good solution to instrument an Ice app. Thanks for that hint! However, the change in this PR should still be merged. Reason being (beside aligning C++ with the other languages) as follows: The dispatch interceptor reads the Tracing context from the Merging this change would allow a dispatch interceptor to remove the parent trace context from the Ice::Context before dispatching, removing that confusion. |
Why does your servant need to access the tracing info form the context? Can't it just retrieve the ActiveSpan setup by the dispatcher? Wouldn't it be best if your servants didn't have to deal at all with the tracing info from the |
The ActiveSpan concept does not appear in the OpenTracing C++ SDK as far as I can tell. In all C++ OpenTracing instrumentation I have seen, spans are put as Maybe there should be (something like a thread-local stack with the most recent (innermost) span on top of the stack), but that's not how the OpenTracing currently works. |
Ok I see, there's a bug about this: opentracing/opentracing-cpp#97. You could indeed implement something similar with thread specific storage but probably not that trivial. |
Note that OpenTracing is getting replaced by OpenTelemetry. |
I don't see a compelling argument here. Your servant code just uses the implicit per-thread context and ignores the current context - sounds pretty simple. Also note that you have to be careful with async calls: AMI calls where the result is retrieved from a different thread and AMD dispatches where the thread supplying the result is not your dispatch thread. Having a modified Current context is not particularly helpful for these async callbacks. Overall I suggest:
See also #417. |
This enables C++ implementations of
Ice::DispatchInterceptor
to modify the incoming request before passing it to the servant. Due to the constness ofIce::Request::getCurrent
, this was impossible before.This brings C++ in line with other language implementations, where such a limitation does not exist, as far as I can tell.
Please let me know if this is something you guys are interested in merging, then I'll send the signed contributor agreement.