-
Notifications
You must be signed in to change notification settings - Fork 99
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
Created working TCP based socket factory impl, but it seemingly breaks after the first flush #374
Comments
The model UDP model doesn't translate directly to TCP as you've discovered. I suspect the errors you're seeing aren't due to flush, but rather your client is disconnecting - when that happens the TCP socket will report EOF. All the SocketFactory invocations happen on startup, we create 1-N sockets and they all receive datagrams, to keep it simple let's just pretend N is 1. The single UDP socket receives all data from all clients, and handles it appropriately. With your TCP implementation, however, when SocketFactory() is called, you call Accept() (which blocks). When you connect, Accept() returns, you return a tcpPacketConnWrapper, and the system is expecting all metrics to be coming through that. The correct way to handle this would be something closer to a single factory, that looks like:
Then the tcpPacketConnWrapper is responsible for:
This is the basic outline, it would need to have things like graceful shutdown, backoff, internal metrics, etc. |
Thank you so much for taking the time to explain this, I really appreciate it! In the future I'll try to contribute to this project to add first-class TCP support, since a lot of OSS can emit statsd metrics over TCP (i.e. Envoy). |
Hello all!
I went ahead and created a socket factory using TCP as the underlying transport, and it for sure works- the gostatsd.Server is definitely flushing metrics that my app is emitting over 8125/tcp. However, after the first flush- I get seemingly thousands of the following log line (and TCP metrics seem to be broken as well, as the log line suggests):
b'time="2021-07-27T23:48:05Z" level=warning msg="Error reading from socket: EOF"'
For reference, here is the TCP based statsd.SocketFactory / net.PacketConn impl I came up with:
The text was updated successfully, but these errors were encountered: