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

Refactored and tested SerializeForLogging #6456

Merged
merged 5 commits into from
Nov 1, 2024

Conversation

jakobht
Copy link
Contributor

@jakobht jakobht commented Oct 31, 2024

What changed?
Refactored SerializeForLogging so we use a wrapper instead of implementing it on every single request type. The function is used to give people implementing custum authorizers the ability to log the request body.

We supported nil receivers in the old interface, so to not break this support we here support typed nils.

Why?
Improve code quality and test coverage

How did you test it?

Potential risks

Release notes

Documentation Changes

Copy link

codecov bot commented Oct 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.18%. Comparing base (40003fc) to head (b4a8a3c).
Report is 23 commits behind head on master.

Additional details and impacted files
Files with missing lines Coverage Δ
common/authorization/authorizer.go 70.90% <100.00%> (+9.93%) ⬆️
common/types/admin.go 69.04% <ø> (+18.30%) ⬆️
common/types/replicator.go 100.00% <ø> (ø)

... and 28 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

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

}

func (f *simpleRequestLogWrapper) SerializeForLogging() (string, error) {
if f.request == nil || reflect.ValueOf(f.request).IsNil() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a bit inefficient, but this is a minor thing in comparison to the next json.Marshal, so should be fine to use

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, I added a comment outlining this

Copy link
Contributor

@Shaddoll Shaddoll left a comment

Choose a reason for hiding this comment

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

Nice!

@jakobht jakobht merged commit 642b5b6 into uber:master Nov 1, 2024
20 checks passed
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.

4 participants