Closed nicpottier closed 3 years ago
Whether it's right or wrong I can explain why it is the way it is. In the goflow/mailroom world we have httpx.Trace
and flows.HTTPLog
(see here). One is the low-level result of the request, the other is that tidied up into something for logging.
httpx.Trace
has the raw data in byte form - it's for handling things which might not even be text responses. The response body and headers are split for convenience. flows.HTTPLog
on the other hand has two valid UTF8 strings for request and response, all ready for writing to a DB record. httpx.Trace
has no opinion about success vs error. When a trace is converted to a HTTPLog
we decide that and by default it's based on 4xx/5xx status codes, but in cases like DTOne, a 2xx response with an error value is considered an error.flows.HTTPLog
supports redaction (i.e. replacing sensitive information) in the request/response traces.So I think I'd argue for keeping that separation of concerns, but maybe HTTPLog
and the redaction stuff belongs in a httplog
package in gocommon.
Ya, that's kind of where I've ended up and it's fine.
Looking to use Trace in swaggo and it is mostly great but there's a few things that feel like they are missing from a DRY perspective:
I guess it is balance between whether we think those two things would cause trouble elsewhere, but I certainly am finding myself wanting to use Trace as a way to say create an HTTPLog as a standalone thing and it isn't so convenient because of the above.
Thoughts @rowanseymour ?