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

Finish Netty 4.1 spans after response has completed not when it started. #2641

Merged
merged 5 commits into from
Mar 27, 2021

Conversation

anuraaga
Copy link
Contributor

Currently, we end an outbound span as soon as headers are sent, even if the data is chunked and it will take some time to send it all. We should end the span after the last (potentially only but still should wait for the I/O) write is finished instead.

Guessing this applies to other Netty instrumentations too but just started with 4.1 to confirm the approach.

@anuraaga
Copy link
Contributor Author

@iNikem your favorite instrumentation!

Comment on lines 37 to 42
// Headers before body has been sent, store them to use when finishing the span.
ctx.channel().attr(HTTP_RESPONSE).set((HttpResponse) msg);
} else if (msg instanceof LastHttpContent) {
// Not a FullHttpResponse so this is content that has been sent after headers. Finish the
// span using what we stored in attrs.
tracer().end(context, ctx.channel().attr(HTTP_RESPONSE).get());
Copy link
Contributor

Choose a reason for hiding this comment

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

I find it confusing that you talk about "sending" here. This is client response handler, it receives data, not sends.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup thanks

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

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

👍

Anuraag Agrawal and others added 3 commits March 27, 2021 12:17
…ntelemetry/javaagent/instrumentation/netty/v4_1/client/HttpClientResponseTracingHandler.java

Co-authored-by: Trask Stalnaker <[email protected]>
…ntelemetry/javaagent/instrumentation/netty/v4_1/server/HttpServerResponseTracingHandler.java

Co-authored-by: Trask Stalnaker <[email protected]>
…ntelemetry/javaagent/instrumentation/netty/v4_1/server/HttpServerResponseTracingHandler.java

Co-authored-by: Trask Stalnaker <[email protected]>
@anuraaga anuraaga merged commit c3c5e6b into open-telemetry:main Mar 27, 2021
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.

3 participants