metrics.Request receives an already drained *http.Response #258
Labels
stale
triage me
I really want to be triaged.
type: feature request
‘Nice-to-have’ improvement, new feature or different behavior or design.
Is your feature request related to a problem? Please describe.
This is somewhat related to #245 in regards of the usefulness of the current
metrics.Request
interfaceAs of now, during the client APIcall execution the http response body is decoded before calling the
EndRequest
method, thus sending a drained response to it:I get that this favors performance but also reduces the efficacy of these metrics interfaces in the first place since, for instance, any manual logging or introspection of the raw JSON payload is not possible
Describe the solution you'd like
I'd like to be able to get the raw JSON response from the executed request
Describe alternatives you've considered
I think a simple, non-obtrusive way would be to extend the
Request
interface with a hook method like the following, to be called before performing the JSON decoding:I get that this is a breaking change on the interface level but an empty implementation should have a negligible performance impact and for debugging or logging scenarios the following pattern can be applied to intercept request payloads:
The text was updated successfully, but these errors were encountered: