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 jaeger-query HTTP handler diagnostic logging #2906

Merged
merged 5 commits into from
Mar 27, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
12 changes: 10 additions & 2 deletions cmd/query/app/http_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,15 @@ func (aH *APIHandler) writeJSON(w http.ResponseWriter, r *http.Request, response
return json.MarshalIndent(v, "", " ")
}
}
resp, _ := marshall(response)
resp, err := marshall(response)
if err != nil {
aH.logger.Error("Failed marshalling HTTP response to JSON", zap.Error(err))
return
}
w.Header().Set("Content-Type", "application/json")
w.Write(resp)
if b, err := w.Write(resp); err != nil {
aH.logger.Error("Failed writing HTTP response", zap.Error(err))
} else {
aH.logger.Debug("Successfully wrote HTTP response", zap.Int("bytes", b))
Copy link
Member

Choose a reason for hiding this comment

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

I'm not a fan of this debug logging, is it necessary? It should be observable from the client side already.

}
}
5 changes: 4 additions & 1 deletion cmd/query/app/http_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,11 @@ func TestPrettyPrint(t *testing.T) {

for _, testCase := range testCases {
t.Run(testCase.param, func(t *testing.T) {
apiHandler := &APIHandler{
logger: zap.NewNop(),
}
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
new(APIHandler).writeJSON(w, r, &data)
apiHandler.writeJSON(w, r, &data)
}))
defer server.Close()

Expand Down