-
Notifications
You must be signed in to change notification settings - Fork 24
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
Propagation of Tracing Context to AWS SDK SqsAsyncClient #262
Comments
For the sake of completeness, there is also awspring/spring-cloud-aws#646 and netty/netty#8546. What you can do as a user is adding a 👍🏼 on the issue description and a comment that you need this. (I saw your comments on the spring-cloud-aws issue. 👍🏼) Reactor Netty is instrumented, as far as I know it has support on the event loop/network level, maybe that's something you can enable and reuse? Also, as far as I can understand, if you want to instrument SQS, you might be on the wrong level for that (network/http level). If you instrument the event loop and add tracing information to the HTTP request that you send to AWS, I don't think that information will be propagated to the client. I think what you should do instead is adding tracing information to the SQS message header (that will be sent to AWS over HTTP) and those are sent to the client when the SQS message is delivered. So instead of instrumenting the low-level HTTP client you should (wrap? and) instrument the SQS client itself. Don't get me wrong, instrumenting Netty could be also useful but I think that's step two and you might not need to do it eventually. |
I am already engaged in awspring/spring-cloud-aws#646 with this PR.
In the discussion, I pointed out that the AWS SDK project manages the Reactor API under the hood and only exposes the SqsAsyncClient based on asynchronous CompletableFuture.
I am already propagating tracing information to SQS with message headers (by using a custom version of SenderContext), but the key is that I would also like to maintain observability of the entire process of Spring Cloud AWS API invocation (including tracing, logging, and metrics). |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Hey, @sondemar ! I've been thinking a bit about your case and here are a few thoughts: It sounds like you assume the underlying AWS implementation always uses the Also, I can’t understand the As far as I understand, the usage is that at some point, within an In Reactor-Netty there is a way to restore TLs for every single task that Netty executes, but it's not recommended due to performance reasons. It could work for debugging purposes, though. The reason that can happen is because Reactor-Netty attaches the |
Hi @chemicL , Thank you for your comprehensive answer! Regarding your thoughts and questions:
I believe it's not common, but possible, as mentioned in the documentation. This executor seems to be executed by threads used by EventLoopGroup.
I wanted to incorporate the concept of the Reactor context view, as mentioned in this article. In my case,
This is exactly the issue—I lose the Observation scope stored in the ThreadLocal at this point.
I believe this refers to ReactorContextAccessor, which I mentioned above. Unfortunately, I do not see a straightforward solution. The last idea that comes to mind is to create a ContextSnapshot and attach it to ExecutionAttributes. This can then be read with a dedicated ExecutionInterceptor and used to populate the ThreadLocal. |
Hi, I am trying to propagate the tracing context with the Micrometer Observation API while using the AWS SDK SqsAsyncClient, which operates on the Netty Event Loop Model.
Even though I have registered
ObservationThreadLocalAccessor
andObservationAwareSpanThreadLocalAccessor
withContextRegistry
, and instrumented executors (configuration details ofSqsAsyncClient
I described in this discussion):I am still unable to access the currently opened scope because the executors are invoked from the Netty EventLoop thread.
I am seeking any possible workaround until the issue is resolved.
The only solution I can think of involves using an implementation of ContextAccessor and a custom
ObservationContextHolder
:where
ObservationContextHolder
properly stores values for the keysObservationThreadLocalAccessor.KEY
andObservationAwareSpanThreadLocalAccessor.KEY
.However, this solution is not thread-safe.
Could you please advise on a proper workaround or solution?
The text was updated successfully, but these errors were encountered: