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

fix(middleware): proper handling of handler status codes in log/metrics middlewares #200

Merged
merged 4 commits into from
Nov 21, 2024

Conversation

samlaf
Copy link
Collaborator

@samlaf samlaf commented Nov 18, 2024

Fixes Issue

Fixes #186

Changes proposed

Screenshots (Optional)

Note to reviewers

@samlaf samlaf requested review from epociask and bxue-l2 November 18, 2024 16:08
// we assume that every route will set the status header
recordDur(w.Header().Get("status"), string(mode), string(versionByte))
return fmt.Errorf("metrics middleware: error parsing version byte: %w", err)
// Some routes don't have a version byte, such as /put simple commitments.
Copy link
Collaborator

Choose a reason for hiding this comment

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

why would /put simple commitments not have a version byte but OP /put would?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch.... I was totally wrong here. I updated to: 096003c
Realized our version bytes are hardcoded for all the PUT routes.. bit ugly how I did some of the routing now I'm realizing. But let me know what you think of these changes. You'll have to change this when you get the v2 changes in.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh also for reference it seems like its the keccak commitments that don't have a version byte:

// we don't use version_byte for keccak commitments, because not expecting keccak commitments to change,

@samlaf samlaf force-pushed the samlaf/fix--middlewares-response-status-code branch from 2561326 to 8bd4b41 Compare November 20, 2024 10:24
@samlaf samlaf requested a review from epociask November 20, 2024 10:36
Copy link
Collaborator

@epociask epociask left a comment

Choose a reason for hiding this comment

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

LGTM

@samlaf samlaf merged commit aeeb503 into main Nov 21, 2024
7 checks passed
@samlaf samlaf deleted the samlaf/fix--middlewares-response-status-code branch November 21, 2024 19:54
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.

middlewares: implement ResponseWriter wrapper to log status code
2 participants