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

Conversation

albertteoh
Copy link
Contributor

Signed-off-by: albertteoh albert.teoh@logz.io

Which problem is this PR solving?

  • Jaeger-query was swallowing json marshalling errors, making it difficult to root-cause issues during development (while adding a new /metrics API endpoint).

Short description of the changes

  • Handle json.Marshal and ResponseWriter.Write errors and log them. Log success at debug level as well.

albertteoh added 2 commits March 26, 2021 23:54
Signed-off-by: albertteoh <albert.teoh@logz.io>
Signed-off-by: albertteoh <albert.teoh@logz.io>
@albertteoh albertteoh requested a review from a team as a code owner March 26, 2021 13:01
@mergify mergify bot requested a review from jpkrohling March 26, 2021 13:01
@codecov
Copy link

codecov bot commented Mar 26, 2021

Codecov Report

Merging #2906 (c275c44) into master (ecd3bbb) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2906      +/-   ##
==========================================
+ Coverage   95.92%   95.94%   +0.01%     
==========================================
  Files         223      223              
  Lines        9704     9708       +4     
==========================================
+ Hits         9309     9314       +5     
+ Misses        326      325       -1     
  Partials       69       69              
Impacted Files Coverage Δ
cmd/query/app/http_handler.go 100.00% <100.00%> (ø)
cmd/query/app/server.go 95.62% <0.00%> (-1.46%) ⬇️
plugin/storage/integration/integration.go 77.90% <0.00%> (+0.55%) ⬆️
cmd/query/app/static_handler.go 96.77% <0.00%> (+1.61%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ecd3bbb...c275c44. Read the comment docs.

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

The error paths can me tested

Signed-off-by: albertteoh <albert.teoh@logz.io>
@albertteoh albertteoh force-pushed the query-diagnostic-logging branch 2 times, most recently from d49f172 to f3eef71 Compare March 26, 2021 22:40
@albertteoh
Copy link
Contributor Author

The error paths can me tested

Yup, sloppiness on my part. I had a go at writing tests for it, please let me know if there's a more idiomatic approach.

if b, err := w.Write(resp); err != nil {
aH.handleError(w, fmt.Errorf("failed writing HTTP response: %w", err), http.StatusInternalServerError)
} 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.

}

// ErrHandlerFunc injects the httpResponseErrWriter into the HTTP handler.
type ErrHandlerFunc func(http.ResponseWriter, *http.Request)
Copy link
Member

Choose a reason for hiding this comment

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

This type isn't necessary, you can inline in L262 using http.HandlerFunc

Signed-off-by: albertteoh <albert.teoh@logz.io>
@yurishkuro yurishkuro merged commit f49c6df into jaegertracing:master Mar 27, 2021
@albertteoh albertteoh deleted the query-diagnostic-logging branch March 28, 2021 03:57
@albertteoh
Copy link
Contributor Author

Thanks for the review!

@jpkrohling jpkrohling added this to the Release 1.23.0 milestone Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants