1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2026-06-03 18:35:08 +02:00

otlptracehttp, otlpmetrichttp: Retry for 502, 504 HTTP statuses (#4670)

This commit is contained in:
Robert Pająk
2023-10-30 19:59:57 +01:00
committed by GitHub
parent fcc1129d0a
commit 509c23eb73
5 changed files with 22 additions and 6 deletions
@@ -190,7 +190,10 @@ func (d *client) UploadTraces(ctx context.Context, protoSpans []*tracepb.Resourc
}
return nil
case sc == http.StatusTooManyRequests, sc == http.StatusServiceUnavailable:
case sc == http.StatusTooManyRequests,
sc == http.StatusBadGateway,
sc == http.StatusServiceUnavailable,
sc == http.StatusGatewayTimeout:
// Retry-able failures. Drain the body to reuse the connection.
if _, err := io.Copy(io.Discard, resp.Body); err != nil {
otel.Handle(err)
@@ -95,7 +95,7 @@ func TestEndToEnd(t *testing.T) {
}),
},
mcCfg: mockCollectorConfig{
InjectHTTPStatus: []int{503, 503},
InjectHTTPStatus: []int{503, 502},
},
},
{
@@ -110,7 +110,7 @@ func TestEndToEnd(t *testing.T) {
}),
},
mcCfg: mockCollectorConfig{
InjectHTTPStatus: []int{503},
InjectHTTPStatus: []int{504},
InjectResponseHeader: []map[string]string{
{"Retry-After": "10"},
},