Skip to content
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

Rework reactor netty context tracking #9286

Merged
merged 5 commits into from
Sep 22, 2023
Merged

Conversation

laurit
Copy link
Contributor

@laurit laurit commented Aug 23, 2023

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 and http.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.

@laurit laurit requested a review from a team as a code owner August 23, 2023 07:50
@laurit laurit marked this pull request as draft August 23, 2023 07:51
Comment on lines +116 to +120

int resendCount = resendCountIncrementer.applyAsInt(parentContext);
if (resendCount > 0) {
attributes.put(SemanticAttributes.HTTP_RESEND_COUNT, resendCount);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍
I don't really remember why I decided to put that in onEnd(), but there should be no problem adding this attribute onStart(), we might as well move it there.

@laurit laurit merged commit c7617dc into open-telemetry:main Sep 22, 2023
47 checks passed
@laurit laurit deleted the reactor-netty branch September 22, 2023 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants