logbook icon indicating copy to clipboard operation
logbook copied to clipboard

Netty Server/Client and Webflux instrumentations don't log POST request body

Open akrysiak-equinix opened this issue 4 years ago • 0 comments

Using logbook we identified that it doesn't log POST request body for Netty Server/Client and Webflux instrumentation.

Description

During investigation appeared that classes like: Request, ClientRequest are initiated with state Unbuffered. The instance of such a class is passed further where the reactive request body is copied into the buffer of the Zalando request. The implementation of the method: buffer of the State:Unbuffered implementation is empty. The method buffer is used to propagate the reactive request body into Zalando's request internal buffer. Seems that there is no way the request body will be logged.

Expected Behavior

The expectation is that a POST request body is logged.

Actual Behavior

Only the request's parameters are logged.

Possible Fix

For now, I've patched org.zalando.logbook.netty.LogbookServerHandler replacing the line: this.request = new Request(context, REMOTE, httpRequest); with this.request = (Request) new Request(context, REMOTE, httpRequest).withBody();

and for org.zalando.logbook.netty.LogbookClientHandler replacing the line: this.request = new Request(context, LOCAL, httpRequest); with this.request = (Request) new Request(context, LOCAL, httpRequest).withBody();

I think that other reactive instrumentation could have such an issue as well.

Steps to Reproduce

  1. Follow the documentation for Netty and WebClient / reactive HttpClient instrumentation
  2. perform a POST request against your endpoint or perform as POST call against a remote service
  3. observe missing POST request body in the log

Context

Regular troubleshooting. For now it's fixed locally.

Your Environment

  • Version used: 2.14.0
  • Link to your project: private

akrysiak-equinix avatar Dec 15 '21 15:12 akrysiak-equinix