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

fix(otel): Map 500 errors to 503 #13173

Merged
merged 6 commits into from
Jun 7, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion pkg/distributor/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,21 @@ func (d *Distributor) PushHandler(w http.ResponseWriter, r *http.Request) {
}

func (d *Distributor) OTLPPushHandler(w http.ResponseWriter, r *http.Request) {
d.pushHandler(w, r, push.ParseOTLPRequest)
interceptor := &OtelErrorHeaderInterceptor{ResponseWriter: w}

d.pushHandler(interceptor, r, push.ParseOTLPRequest)
}

type OtelErrorHeaderInterceptor struct {
http.ResponseWriter
}

func (i *OtelErrorHeaderInterceptor) WriteHeader(statusCode int) {
if statusCode == http.StatusInternalServerError {
i.ResponseWriter.WriteHeader(http.StatusServiceUnavailable)
} else {
i.ResponseWriter.WriteHeader(statusCode)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment why we are doing this, e.g. link the OTLP spec https://opentelemetry.io/docs/specs/otlp/#failures-1

}

func (d *Distributor) pushHandler(w http.ResponseWriter, r *http.Request, pushRequestParser push.RequestParser) {
Expand Down
Loading