minio-go icon indicating copy to clipboard operation
minio-go copied to clipboard

Object is not traced when the request returns an error

Open agnivade opened this issue 3 years ago • 2 comments

In this line https://github.com/minio/minio-go/blob/ff482a18933aa30769bfaeb7d34fa680fa51bcee/api.go#L491, we can see that if there is an error while making the request, the code returns and therefore no trace logging happens. This is unexpected behavior and makes things hard to debug. Even if the response doesn't come, the tracing logs both request and response. So it's always expected to log the request regardless of the response.

I'd suggest to split the method into 2 parts: first logging the request unconditionally, then logging the response along with the condition of && resp.StatusCode == http.StatusOK.

Due to this, we are unable to debug connection failures from object storage: https://github.com/mattermost/mattermost-server/issues/19584

agnivade avatar Jun 13 '22 04:06 agnivade

In this line

https://github.com/minio/minio-go/blob/ff482a18933aa30769bfaeb7d34fa680fa51bcee/api.go#L491

The error will be displayed at the end @agnivade - we only print when the "request" was actually sent and we did get a "Response" back.

Currently, it's not implemented to print tracing for network errors. The main reason is we use Go's httputil to print the relevant trace format.

Let's see if we can add this to the trace.

harshavardhana avatar Jun 13 '22 05:06 harshavardhana

Thanks @harshavardhana

we only print when the "request" was actually sent and we did get a "Response" back.

Yes, that is the problem here. Due to this, the user does not know exactly which requests are failing which makes things hard to debug. I'd suggest to log the request unconditionally, and then log the response with the same logic as you are doing now.

Currently, it's not implemented to print tracing for network errors. The main reason is we use Go's httputil to print the relevant trace format.

You just need to display the request using httputil.DumpRequestOut.

agnivade avatar Jun 13 '22 09:06 agnivade