Skip to content

Commit

Permalink
Add support to handle 402, 413, 414, 431 http error code as permanent…
Browse files Browse the repository at this point in the history
… errors in OTLP exporter open-telemetry#5674

 - fixed according to code review
  • Loading branch information
mcmho committed Jul 21, 2022
1 parent 0783f92 commit 69031c5
Showing 1 changed file with 7 additions and 13 deletions.
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

0 comments on commit 69031c5

Please sign in to comment.