Rework reactor netty context tracking #9286
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Despite previous attempts reactor netty redirect tests are still flaky.
https://ge.opentelemetry.io/s/35kxioqhifawm/tests/task/:instrumentation:reactor:reactor-netty:reactor-netty-1.0:javaagent:test/details/io.opentelemetry.javaagent.instrumentation.reactornetty.v1_0.ReactorNettyHttpClientTest/redirectToSecuredCopiesAuthHeader()?expanded-stacktrace=WyIwIl0&top-execution=1
In the flaky test output we have
http.url=http://localhost:38413/to-secured http.status_code=200
andhttp.url=http://localhost:38413/secured http.status_code=302
which indicates that responses are swapped for these requests.As reactor netty request and response are really the same object that is accessed through different interfaces we can just cast the response to request and attach context to it, which should allow as accurately match requests with responses. Requests with error where response is null (I think it has to be some kind of connection error, like timeout or wrong port) for this to happen will still use the queue. Also I moved filling resend count from end to start which should ensure that we add it to the correct span as start, unlike end, is called in correct order.