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

Incorrect logging protobuf requests/responces #1330

Open
juncevich opened this issue Jun 7, 2022 · 16 comments
Open

Incorrect logging protobuf requests/responces #1330

juncevich opened this issue Jun 7, 2022 · 16 comments

Comments

@juncevich
Copy link

Useless converting raw bytes from request(response) bodies broke protobuf model deserialization.

Description

Protobuf response body incorrect deserializing, because FilteredHttpRequest(FilteredHttpResponse).getBody() converts body to string and after that convert string to byte array. Which cause to brake model from body. For example, if i have raw body bytes array size 170, response.getBody() array of bytes size will 250, because it was converted to string.

Expected Behavior

FilteredHttpRequest.getBody() gives raw bytes, without converting to string.

Actual Behavior

изображение

Possible Fix

getBody must contains raw bytes from response

@juncevich juncevich added the Bug label Jun 7, 2022
@juncevich
Copy link
Author

Can fix it ASAP.

@skjolber
Copy link
Contributor

@juncevich out of interest, which web server are you running?

@juncevich
Copy link
Author

@skjolber Netty with Micronaut.

@skjolber
Copy link
Contributor

I wonder if gRPC logging might be better served with a gRPC-centric module. At least thats how we're doing it internally (emulating the Logbook output format).

Also the HTTP 2 does not follow a strict request-response any more, with 1-n, n-1 or n-n combinations, not sure whether logbook will work as-is now @whiskeysierra?

@juncevich
Copy link
Author

juncevich commented Jul 17, 2022

I've offered not to convert body to string in method byte[] getBody(). I suppose when when someone asked body in bytes - bytes must be raw. There is no need to convert body to string and after it convert to bytes. If i want body as string a can use String getBody(). I mean that problem not in gRPC, and fix in byte[] getBody() will fix the problem.

@whiskeysierra
Copy link
Collaborator

Actual Behavior

изображение

Is that the default implementation right now?

@juncevich
Copy link
Author

Yep

public byte[] getBody() throws IOException {

@whiskeysierra
Copy link
Collaborator

Mmh, I see a bigger problem now.
The idea of filtering (the content or body) is done using a BodyFilter:

public interface BodyFilter {
String filter(@Nullable final String contentType, final String body);

As you can see, the interface that we defined here takes a String and returns a String.
This would need to change from String to byte[].

@juncevich
Copy link
Author

@whiskeysierra Will we fix these problems? I can do it)

@juncevich juncevich changed the title Invorrect logging protobuf requests/responces Incorrect logging protobuf requests/responces Feb 23, 2023
@whiskeysierra
Copy link
Collaborator

Will we fix these problems? I can do it)

I'd love to, but it sounds like a breaking change, tbh.

@whiskeysierra
Copy link
Collaborator

Useless converting raw bytes from request(response) bodies broke protobuf model deserialization.

@juncevich Just curious, do you just use protobuf over HTTP? I'm thinking how to integrate Logbook with gRPC and I'm looking for ways to do that cleanly.

@skjolber
Copy link
Contributor

skjolber commented May 8, 2023

FYI we are using grpc-java and grpc-netty with subclasses of io.grpc.ServerInterceptor.

@whiskeysierra
Copy link
Collaborator

whiskeysierra commented May 8, 2023 via email

@skjolber
Copy link
Contributor

skjolber commented May 8, 2023

Yes. I've extracted the relevant subset of our internal logging project and published it here, it still needs some cleanups, but it is a fully working example (at least the unit tests run).

You'll notice that Logbook is not in use at all, however the output (JSON) format is essentially the same as in Logbook.

Also the gRPC stack typically lets us return a ton of responses for a single request, this turned out to be too noisy for our taste, so we added some "summary" request-response message types.

@juncevich
Copy link
Author

Useless converting raw bytes from request(response) bodies broke protobuf model deserialization.

@juncevich Just curious, do you just use protobuf over HTTP? I'm thinking how to integrate Logbook with gRPC and I'm looking for ways to do that cleanly.

Yes.

Copy link
Contributor

In order to prioritize the support for Logbook, we would like to check whether the old issues are still relevant.
This issue has not been updated for over six months.

  • Please check if it is still relevant in latest version of the Logbook.
  • If so, please add a descriptive comment to keep the issue open.
  • Otherwise, the issue will automatically be closed after a week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants