promhttp: Ignore informational response status codes when handling response#1773
Open
VirrageS wants to merge 1 commit intoprometheus:mainfrom
Open
promhttp: Ignore informational response status codes when handling response#1773VirrageS wants to merge 1 commit intoprometheus:mainfrom
VirrageS wants to merge 1 commit intoprometheus:mainfrom
Conversation
…sponse Signed-off-by: Janusz Marcinkiewicz <januszm@nvidia.com>
bwplotka
reviewed
Apr 24, 2025
Member
bwplotka
left a comment
There was a problem hiding this comment.
Amazing! Any chances for a small unit test to ensure this works correctly long term? 🤗
Otherwise LGTM!
| if !r.wroteHeader { | ||
| // Ignore informational response status codes. | ||
| // Based on https://github.com/golang/go/blob/go1.24.1/src/net/http/server.go#L1216 | ||
| if code >= 100 && code <= 199 && code != http.StatusSwitchingProtocols { |
Member
There was a problem hiding this comment.
What about something like:
Suggested change
| if code >= 100 && code <= 199 && code != http.StatusSwitchingProtocols { | |
| if code / 100 == 1 && code != http.StatusSwitchingProtocols { |
Author
There was a problem hiding this comment.
As mentioned, this code is based on the server.go implementation and I wanted to preserve the whole syntax so it is clear.
I can change that but I don't see a reason to do that since it is clear what this code does now. And code / 100 == 1 doesn't make it faster or more clear.
Member
|
@VirrageS Do you want to take care of the comments? We will have a release soon and we can include this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1772