Source File
error.go
Belonging Package
go.pact.im/x/traces/otlptraces
package otlptracesimport ()const headerRetryAfter = "Retry-After"// HTTPError is returned by [Exporter.Export] when the collector responds with a// non-2xx HTTP status code.type HTTPError struct {// StatusCode is the HTTP response status code.StatusCode int// Header is the HTTP response header.Header http.Header// Body is a prefix of the response body (up to 4 KiB).Body string}// Error implements the error interface.func ( *HTTPError) () string {return fmt.Sprintf("otlptraces: HTTP %d: %s", .StatusCode, .Body)}// Retryable reports whether the OTLP specification permits retrying the// request (429, 502, 503, 504).func ( *HTTPError) () bool {switch .StatusCode {case http.StatusTooManyRequests,http.StatusBadGateway,http.StatusServiceUnavailable,http.StatusGatewayTimeout:return truedefault:return false}}// RetryAfter parses the Retry-After response header relative to now.// It returns 0 if the header is absent, invalid, or not in the future.func ( *HTTPError) ( time.Time) time.Duration {:= .Header.Get(headerRetryAfter)if == "" {return 0}if , := strconv.Atoi(); == nil {if > 0 {return time.Duration() * time.Second}return 0}if , := http.ParseTime(); == nil {if := .Sub(); > 0 {return}}return 0}
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64)