Skip to content

Commit aba76f1

Browse files
committed
documentation
1 parent a253bb5 commit aba76f1

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ public class Foo {
6060

6161
Unix Domain Socket support
6262
---------------------------
63-
java.io.IOException: No such file or directory
64-
java.io.IOException: No buffer space available
63+
64+
As an alternative to UDP, Agent6 can receive metrics via a UNIX Socket (on Linux only). This library supports
65+
transmission via this protocol. To use it, simply pass the socket path as a hostname, and 0 as port.
66+
67+
By default, all exceptions are ignored, mimicking UDP behaviour. When using Unix Sockets, transmission errors will
68+
trigger exceptions you can choose to handle by passing a `StatsDClientErrorHandler`:
69+
70+
- Connection error because of an invalid/missing socket will trigger a `java.io.IOException: No such file or directory`
71+
- If dogstatsd's reception buffer were to fill up, the send will timeout after 100ms and throw either a
72+
`java.io.IOException: No buffer space available` or a `java.io.IOException: Resource temporarily unavailable`
6573

src/main/java/com/timgroup/statsd/NonBlockingStatsDClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,8 @@ public NonBlockingStatsDClient(final String prefix, final int queueSize, String
319319
final SocketAddress address = addressLookup.call();
320320
if (address instanceof UnixSocketAddress) {
321321
clientChannel = UnixDatagramChannel.open();
322+
// Set send timeout to 100ms, to handle the case where the transmission buffer is full
323+
// If no timeout is set, the send becomes blocking
322324
clientChannel.setOption(UnixSocketOptions.SO_SNDTIMEO, Integer.valueOf(100));
323325
} else{
324326
clientChannel = DatagramChannel.open();

0 commit comments

Comments
 (0)