-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Make caser a local varialbe, not a global one. #927
Conversation
The cases.Caser returned by calling cases.Title *cannot* be shared among goroutines. This might happen when Prometheus tries to scrape multiple targets at the same time. From the docs: A Caser may be stateful and should therefore not be shared between goroutines. Fixes: #922 Signed-off-by: Marcelo E. Magallon <[email protected]>
a0a6364
to
19016d2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm 👍
There's an open PR in BBE to fix an issue with reusing a golang.org/x/text/cases/Caser: prometheus/blackbox_exporter#927 Signed-off-by: Marcelo E. Magallon <[email protected]>
There's an open PR in BBE to fix an issue with reusing a golang.org/x/text/cases/Caser: prometheus/blackbox_exporter#927 Signed-off-by: Marcelo E. Magallon <[email protected]>
// | ||
// A Caser may be stateful and should therefore not be shared between goroutines. | ||
// | ||
// Issue: https://github.com/prometheus/blackbox_exporter/issues/922 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it is necessary to point to the gh issue here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I felt it was necessary to keep the reference close to the code because the original version is what I would have written, too. The wording in the docs, "a Caser may", sounds like if that were the actual case, the individual Caser implementations would spell that out. Given that in this particular instance there no such note, I would have assumed that this Caser is not stateful.
Thanks for the review and merging this!
The cases.Caser returned by calling cases.Title cannot be shared among
goroutines. This might happen when Prometheus tries to scrape multiple
targets at the same time. From the docs:
A Caser may be stateful and should therefore not be shared between
goroutines.
Fixes: #922
Signed-off-by: Marcelo E. Magallon [email protected]