-
Notifications
You must be signed in to change notification settings - Fork 215
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: request body logging [#84] #94
Conversation
@flash286 thank you for the pull request! The approach looks good. I would like to investigate a bit more before merging. In particular, look at the integrations that use FromHTTPRequest -- it may be the case that the body was read and is not available anymore when we want to report an error. Will give more review feedback tomorrow, wanted to keep you posted ;) Once again thank you! |
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.
@flash286 thanks for your contribution! Special awesomeness medal 🥇 for adding tests!
I'd like @kamilogorek to have a look at this too as he may have some insights.
interfaces_test.go
Outdated
|
||
const testPayload = `{"test_data": true}` | ||
|
||
func TestRequest_FromHTTPRequest(t *testing.T) { |
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 awesome to see tests for this, thank you very much!!! ❤️
We follow the Go MixedCaps naming convention, could you please update the function name to TestRequestFromHTTPRequest
?
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.
fixed
interfaces_test.go
Outdated
sentryRequest := Request{} | ||
sentryRequest = sentryRequest.FromHTTPRequest(req) | ||
assertEqual(t, sentryRequest.Data, testPayload) | ||
}) |
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.
The body of the first test is exactly the same as the early portion of the second test.
Since the assert*
helpers call t.Error
, execution continues even after an "assertion error". In that case, I think it is enough to have just the second test.
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.
I Agree, second one should cover all we need
interfaces_test.go
Outdated
"testing" | ||
) | ||
|
||
const testPayload = `{"test_data": true}` |
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.
Since this is not used anywhere else and to avoid polluting the global namespace for tests, how about we move this inside of the test method?
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.
fixed
Agree with all your comments, nice review! |
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.
@flash286 thanks for the update! I noticed one opportunity to capture the body bytes even when there's an error. Would you like to tackle it in this PR? Extra bonus if that includes a unit test 😄
Otherwise let's merge this in and cut an improvement issue.
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.
Let's get this in and iterate later if we need.
@flash286 thank you very much for your contribution! |
fix: request body logging [#84]