Skip to content

Capture HTTP2 headers in netty gRPC client/server #158

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

Merged
merged 7 commits into from
Dec 9, 2020

Conversation

pavolloffay
Copy link
Member

Signed-off-by: Pavol Loffay p.loffay@gmail.com

Updates #109

Signed-off-by: Pavol Loffay <p.loffay@gmail.com>
Signed-off-by: Pavol Loffay <p.loffay@gmail.com>
Signed-off-by: Pavol Loffay <p.loffay@gmail.com>
}
}

static class Utils_convertClientHeaders_Advice {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: GrpcUtils maybe?

Copy link
Member Author

Choose a reason for hiding this comment

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

The target class is called Utils therefore the Utils name.

isMethod().and(named("convertClientHeaders")).and(takesArguments(6)),
Utils_convertClientHeaders_Advice.class.getName());
transformers.put(
isMethod().and(named("convertHeaders")).and(takesArguments(1)),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is called multiple times from different flows in code.. How are we keeping track when to use and when not to use?

Copy link
Member Author

Choose a reason for hiding this comment

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

correct we do not keep track of objects where should be added. I want to avoid using TLS and global map to do this as it is done in the old impl.

The HTTP2 headers are added under different keys than the gRPC impl uses e.g. :method.ht to do not collide with user app. The implementation does not change any objects it just adds more data to metadata object passed around I think this is acceptable also the added headers are not added to the wire.

For completion: this advice does not change client response headers since those headers do not have the HTTP2 we are using (see the comment in the code). If the server side will cause any issues we could remove added headers in the interceptor before passing it to user define interceptors. The removal seems expensive so I would rather skip it for now.

@Advice.Argument(3) Object authority,
@Advice.Argument(4) Object method) {

Span currentSpan = Java8BytecodeBridge.currentSpan();
Copy link
Collaborator

Choose a reason for hiding this comment

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

This method can be called when a span does not exist right? We need to add these attributes only when some span has been started.. Are we tracking that? If yes, then span can be null -- need to handle that..

Copy link
Member Author

@pavolloffay pavolloffay Dec 9, 2020

Choose a reason for hiding this comment

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

span is never null. It is either DefaultSpan or recording events span.


if (http2Headers.authority() != null) {
metadata.put(
GrpcSemanticAttributes.AUTHORITY_METADATA_KEY, http2Headers.authority().toString());
Copy link
Collaborator

Choose a reason for hiding this comment

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

we are changing original user metadata object -- need to be very careful if this does not break anything -- especially since this method is called from different flows in code..

Signed-off-by: Pavol Loffay <p.loffay@gmail.com>
Signed-off-by: Pavol Loffay <p.loffay@gmail.com>
Signed-off-by: Pavol Loffay <p.loffay@gmail.com>
Signed-off-by: Pavol Loffay <p.loffay@gmail.com>
@pavolloffay pavolloffay changed the title Capture HTTP2 headers in gRPC client/server Capture HTTP2 headers in netty gRPC client/server Dec 9, 2020
@pavolloffay pavolloffay merged commit f4fa189 into hypertrace:main Dec 9, 2020
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.

2 participants