-
Notifications
You must be signed in to change notification settings - Fork 137
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
Exposing #close as a public method, to help consumers avoid using too many file descriptors #46
Conversation
… many file descriptors
Hi @ramfjord, thanks for your contribution! I'm fine with exposing For the retry part: could we make sure we retry only once? Even though it's unlikely to happen, I'd prefer to avoid any risk of unbounded error loop. |
…o a closed socket, and that we rescue errors from connect_to_socket when we try to reconnect
@degemer I'm not sure if |
@@ -13,8 +13,6 @@ class Datadog::Statsd | |||
@statsd.socket = FakeUDPSocket.new | |||
end | |||
|
|||
after { @statsd.socket.clear } |
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'm pretty sure this isn't necessary because the before
clause always initializes a new socket. If I can remove it, I can also remove the after
clause in the #close
tests, without having to mock out #clear
.
…the socket after each test, since we're reinitializing it before each test in any case
5b440a5
to
081b33b
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.
Thanks a lot for the changes and the tests!
LGTM, it will be part of the next release (targeting end of next week).
Um… I’m running multiple threads on JRuby, so I have “true” concurrency — no GIL. Should I be creating an instance of |
It seems like a common use case for this client would be logging events in a web server. Many of these spin up a thread per response, or delegate response to a thread/process pool. My assumption is that these different threads/processes should not share the same Datadog::Statsd client, since I didn't see any sort of locking implemented around the socket IO.
For our use case, we don't mind creating a new UDPSocket every time we log a set of metrics, so I'd like to be able to close the socket when I'm done to avoid using thousands of file descriptors before the object get garbage collected. Please let me know if this is acceptable, or if I'm perhaps missing some more common way of using this library.