Skip to content

Conversation

@iand675
Copy link
Contributor

@iand675 iand675 commented Jul 27, 2022

We ran into an alert where an internal invariant had been broken in the ReqSketch library. 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.

Copy link
Collaborator

@jml jml left a comment

Choose a reason for hiding this comment

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

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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion: Add a comment explaining why we are masking here. Something along the lines of your PR description would be great.

Copy link
Owner

Choose a reason for hiding this comment

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

+1 on adding a comment directly to the code.

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.

3 participants