Fix async interrupt breaking bookkeeping in a Summary#66
Open
iand675 wants to merge 1 commit intofimad:masterfrom
Open
Fix async interrupt breaking bookkeeping in a Summary#66iand675 wants to merge 1 commit intofimad:masterfrom
iand675 wants to merge 1 commit intofimad:masterfrom
Conversation
jml
reviewed
Jul 28, 2022
Collaborator
jml
left a comment
There was a problem hiding this comment.
Thanks so much!
I've been out of the loop on prometheus-haskell for a while, so if another more active contributor comes along to do the review, please trust them over me.
I've tried to use https://conventionalcomments.org/ in my comments. I hope they are helpful.
| instance Observer Summary where | ||
| -- | Adds a new observation to a summary metric. | ||
| observe s v = doIO $ withMVar (reqSketch s) (`ReqSketch.insert` v) | ||
| observe s v = doIO $ withMVarMasked (reqSketch s) (\rs -> rs `ReqSketch.insert` v) |
Collaborator
There was a problem hiding this comment.
Question: What's the motivation for adding the \rs -> rs bit?
No particular objections, just curious.
| instance Observer Summary where | ||
| -- | Adds a new observation to a summary metric. | ||
| observe s v = doIO $ withMVar (reqSketch s) (`ReqSketch.insert` v) | ||
| observe s v = doIO $ withMVarMasked (reqSketch s) (\rs -> rs `ReqSketch.insert` v) |
Collaborator
There was a problem hiding this comment.
Suggestion: Add a comment explaining why we are masking here. Something along the lines of your PR description would be great.
Owner
There was a problem hiding this comment.
+1 on adding a comment directly to the code.
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.
We ran into an alert where an internal invariant had been broken in the
ReqSketchlibrary. As best as we can tell, it was triggered by an async interrupt causing an internal counter and array length to become out of sync.