refactor(go-forwarder): add HTTP middleware and consolidate forwarding#1135
Conversation
|
|
||
| if err != nil { | ||
| slog.LogAttrs(req.Context(), slog.LevelWarn, "request failed", append(attrs, slog.String("error", err.Error()))...) | ||
| continue |
There was a problem hiding this comment.
In case of error here, we continue (retry) without waiting some time. Is it what we want?
There was a problem hiding this comment.
This error check is for requests that failed to be created (or something went wrong in the middleware stack). We don't want to retry those since they haven't reach the intake endpoint, hence we instantly retry them without waiting.
There was a problem hiding this comment.
(e.g. DNS lookup fail should just retry after some time bc it could be transient)
This comment has been minimized.
This comment has been minimized.
8b93f8d to
f846620
Compare
| func WithCompression(next http.RoundTripper) RoundTripperFunc { | ||
| return func(req *http.Request) (*http.Response, error) { | ||
| var buf bytes.Buffer | ||
| gz := gzip.NewWriter(&buf) |
| return func(req *http.Request) (*http.Response, error) { | ||
| buf := getBuffer() | ||
| gz := getGzipWriter() | ||
| defer bufPool.Put(buf) |
There was a problem hiding this comment.
@ViBiOh If a middleware layer call WithCompression, it may access the buffer/body of another goroutine. Should I make something about that or I can assume that I will always have the WithCompression as the first layer ?
What does this PR do?
Refactors the forwarding package to use HTTP middleware and enhance errors/logging/retry on intake failures
Motivation
Testing Guidelines
Additional Notes
Types of changes
Check all that apply