-
Notifications
You must be signed in to change notification settings - Fork 43
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
Mutex in CaptureMetricsFn #13
Comments
IIRC I added this mutex because the application could definitely call |
I think the same that concurrent write calls are not a normal use. I just have a hesitation even if the order of written data is incorrect, one might implement some kind of packet data and write packets concurrently. If a call to |
I'm not sure I completely follow your last comment. Anyway, the way I look at it is: In the worst case the mutex is redundant overhead. In the best case it will prevent bugs. Precautionary principle slightly guides me towards keeping it. But I could be convinced otherwise if somebody wants to do some more research. Is the presence of the mutex causing you any issues for now? |
No, there is not any issue for now. I just want to learn why mutex is used. I didn't checked the http code yet but |
I think ebati was pointing out that if an application has multiple goroutines writing to the same Writer, a mutex is enough to ensure the correct ordering when each Write is a complete unit of data, like a log line. If the goroutines Write partial data, only the application knows how those goroutines need to be synchronized and the mutex does not add safety. I'm inclined to say that it's the application's responsibility to serialize access to a ResponseWriter, so the mutex is unnecessary. |
I opened an issue in opentelemetry-go-contrib about using this library.
I will send a PR to add another hook for
ReadFrom
but i am not sure why the mutex in your implementation ofCaptureMetricsFn
is used. Is concurrent call to those functions possible or is there any reason to use mutex in this context?The text was updated successfully, but these errors were encountered: