Ensure reactor netty spans are ended in the order they were started (#9203)

This commit is contained in:
Lauri Tulmin 2023-08-16 15:53:10 +03:00 committed by GitHub
parent 31b90b1463
commit 82118868bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -52,7 +52,10 @@ final class InstrumentationContexts {
return context;
}
void endClientSpan(@Nullable HttpClientResponse response, @Nullable Throwable error) {
// we are synchronizing here to ensure that spans are ended in the oder they are read from the
// queue
synchronized void endClientSpan(
@Nullable HttpClientResponse response, @Nullable Throwable error) {
RequestAndContext requestAndContext = clientContexts.poll();
if (requestAndContext != null) {
instrumenter().end(requestAndContext.context, requestAndContext.request, response, error);