-
Notifications
You must be signed in to change notification settings - Fork 530
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 Content-Type header on query-frontend paths #1306
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,7 @@ func (q *Querier) TraceByIDHandler(w http.ResponseWriter, r *http.Request) { | |
http.Error(w, err.Error(), http.StatusInternalServerError) | ||
return | ||
} | ||
w.Header().Set(api.HeaderContentType, api.HeaderAcceptProtobuf) | ||
_, err = w.Write(b) | ||
if err != nil { | ||
http.Error(w, err.Error(), http.StatusInternalServerError) | ||
|
@@ -94,6 +95,7 @@ func (q *Querier) TraceByIDHandler(w http.ResponseWriter, r *http.Request) { | |
http.Error(w, err.Error(), http.StatusInternalServerError) | ||
return | ||
} | ||
w.Header().Set(api.HeaderContentType, api.HeaderAcceptJSON) | ||
} | ||
|
||
// return values are (blockStart, blockEnd, queryMode, error) | ||
|
@@ -193,6 +195,7 @@ func (q *Querier) SearchHandler(w http.ResponseWriter, r *http.Request) { | |
http.Error(w, err.Error(), http.StatusInternalServerError) | ||
return | ||
} | ||
w.Header().Set(api.HeaderContentType, api.HeaderAcceptJSON) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. set content type in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mhm, that's a good point 🤔 The TraceByID path is a bit odd because eventually it all reaches the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sadly I think Since we are adding the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done 👍 |
||
} | ||
|
||
func (q *Querier) SearchTagsHandler(w http.ResponseWriter, r *http.Request) { | ||
|
@@ -217,6 +220,7 @@ func (q *Querier) SearchTagsHandler(w http.ResponseWriter, r *http.Request) { | |
http.Error(w, err.Error(), http.StatusInternalServerError) | ||
return | ||
} | ||
w.Header().Set(api.HeaderContentType, api.HeaderAcceptJSON) | ||
} | ||
|
||
func (q *Querier) SearchTagValuesHandler(w http.ResponseWriter, r *http.Request) { | ||
|
@@ -249,4 +253,5 @@ func (q *Querier) SearchTagValuesHandler(w http.ResponseWriter, r *http.Request) | |
http.Error(w, err.Error(), http.StatusInternalServerError) | ||
return | ||
} | ||
w.Header().Set(api.HeaderContentType, api.HeaderAcceptJSON) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's weird that we assume protobuf here b/c of a header that was set in frontend.go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not, the Trace Sharder only ever sends a protobuf message, it's then unmarshalled and re-marshalled back into either protobuf or json in the
frontend.go
in thenewTraceByIDMiddleware
function hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, I meant it's weird we assume that the data received in the trace by id sharder (from the querier) is proto, but the only reason it is proto is because a header that's set in frontend.go.
I think we should set the
Accept
for proto intracebyidsharding.go
since that code also assumes that the returned data is proto. But these gross corners have been around for long before you made this improvement.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see! I assumed this was intentional after reading the comment on that same line you linked, I guess it kinda make sense to keep content negotiation as close the edge as possible? Then again if internal communication is expected to be only protobuf, then setting the Accept header might just be superfluous 🤷