Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to handle 402, 413, 414, 431 http error code as permanent errors in OTLP exporter #5674 #5685

Merged
merged 12 commits into from
Jul 25, 2022
Merged
Prev Previous commit
Next Next commit
Add support to handle 402, 413, 414, 431 http error code as permanent…
… errors in OTLP exporter #5674

 - fixed according to code review
  • Loading branch information
mcmho committed Jul 21, 2022
commit 69031c5fdcc03b3bfabbeaa1a2ca59140c6d9af9
20 changes: 7 additions & 13 deletions exporter/otlphttpexporter/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,29 +188,23 @@ func (e *exporter) export(ctx context.Context, url string, request []byte) error
}

func isPermanentClientFailure(code int) bool {
var isPermanentError bool

switch code {
case http.StatusBadRequest:
// 400 - bad request
isPermanentError = true
return true
case http.StatusPaymentRequired:
// 402 - payment required typically means that an auth token isn't valid anymore and as such, we deem it as permanent
isPermanentError = true
return true
case http.StatusRequestEntityTooLarge:
// 413 - request size is too large
isPermanentError = true
return true
case http.StatusRequestURITooLong:
// 414 - uri is too long
isPermanentError = true
return true
case http.StatusRequestHeaderFieldsTooLarge:
// 431 - headers too large
isPermanentError = true
return true
default:
isPermanentError = false
return false
}

return isPermanentError
return false
}

// Read the response and decode the status.Status from the body.
Expand Down