Skip to content

Commit 19ec950

Browse files
committed
Cleanup imports
1 parent d50bb85 commit 19ec950

5 files changed

Lines changed: 20 additions & 22 deletions

File tree

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,32 @@ The client jar is distributed via Maven central, and can be downloaded [from Mav
2323

2424
### Unix Domain Socket support
2525

26-
As an alternative to UDP, Agent v6 can receive metrics via a UNIX Socket (on Linux only). This library supports transmission via this protocol. To use it, pass the socket path as a hostname, and `0` as port.
26+
As an alternative to UDP, Agent v6 can receive metrics via a UNIX Socket (on Linux only). This library supports transmission via this protocol. To use it, pass the socket path as a hostname, and `0` as port
27+
or use the `socket()` method of the builder.
28+
29+
```java
30+
StatsDClient client = new NonBlockingStatsDClientBuilder()
31+
.hostname("/var/run/datadog/dsd.socket")
32+
.port(0) // Necessary for unix socket
33+
.build();
34+
```
35+
36+
or
37+
38+
```java
39+
StatsDClient client = new NonBlockingStatsDClientBuilder()
40+
.socket("/var/run/datadog/dsd.socket")
41+
.build();
42+
```
2743

2844
By default, all exceptions are ignored, mimicking UDP behaviour. When using Unix Sockets, transmission errors trigger exceptions you can choose to handle by passing a `StatsDClientErrorHandler`:
2945

3046
- Connection error because of an invalid/missing socket triggers a `java.io.IOException: No such file or directory`.
3147
- If DogStatsD's reception buffer were to fill up and the non blocking client is used, the send times out after 100ms and throw either a `java.io.IOException: No buffer space available` or a `java.io.IOException: Resource temporarily unavailable`.
3248

49+
The default UDS transport is using `SOCK_DATAGRAM` sockets. We also have experimental support for `SOCK_STREAM` sockets which can
50+
be enabled by using the `socket()` method of the builder. This is not recommended for production use at this time.
51+
3352
## Configuration
3453

3554
Once your DogStatsD client is installed, instantiate it in your code:

src/test/java/com/timgroup/statsd/UnixDatagramSocketDummyStatsDServer.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package com.timgroup.statsd;
22

33
import java.io.IOException;
4-
import java.nio.Buffer;
54
import java.nio.ByteBuffer;
65
import java.nio.channels.DatagramChannel;
7-
import java.nio.charset.StandardCharsets;
86
import jnr.unixsocket.UnixDatagramChannel;
97
import jnr.unixsocket.UnixSocketAddress;
108

src/test/java/com/timgroup/statsd/UnixSocketTest.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
package com.timgroup.statsd;
22

3-
import java.net.SocketAddress;
4-
import java.util.Arrays;
5-
import java.util.Collection;
6-
import java.util.concurrent.Callable;
73
import java.util.logging.Logger;
8-
import jnr.unixsocket.UnixSocketAddress;
94
import org.junit.After;
105
import org.junit.Assume;
116
import org.junit.Before;
@@ -14,10 +9,7 @@
149
import java.io.IOException;
1510
import java.io.File;
1611
import java.nio.file.Files;
17-
import org.junit.runner.RunWith;
18-
import org.junit.runners.Parameterized;
1912

20-
import static org.hamcrest.CoreMatchers.anyOf;
2113
import static org.hamcrest.MatcherAssert.assertThat;
2214
import static org.hamcrest.Matchers.contains;
2315
import static org.hamcrest.Matchers.nullValue;

src/test/java/com/timgroup/statsd/UnixStreamSocketDummyStatsDServer.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
package com.timgroup.statsd;
22

3-
import com.sun.xml.internal.ws.api.message.Packet;
43
import java.io.IOException;
54
import java.nio.Buffer;
65
import java.nio.ByteBuffer;
76
import java.nio.ByteOrder;
8-
import java.nio.channels.SelectionKey;
97
import java.nio.channels.SocketChannel;
10-
import java.nio.channels.spi.AbstractSelector;
11-
import java.nio.charset.StandardCharsets;
12-
import java.util.ArrayList;
13-
import java.util.List;
148
import java.util.concurrent.ConcurrentLinkedQueue;
159
import java.util.logging.Logger;
16-
import jnr.enxio.channels.NativeSelectorProvider;
1710
import jnr.unixsocket.UnixServerSocketChannel;
1811
import jnr.unixsocket.UnixSocketAddress;
1912
import jnr.unixsocket.UnixSocketChannel;
@@ -23,7 +16,6 @@
2316
public class UnixStreamSocketDummyStatsDServer extends DummyStatsDServer {
2417
private final UnixServerSocketChannel server;
2518
private final ConcurrentLinkedQueue<UnixSocketChannel> channels = new ConcurrentLinkedQueue<>();
26-
private final ConcurrentLinkedQueue<Packet> packets = new ConcurrentLinkedQueue<>();
2719

2820
private final Logger logger = Logger.getLogger(UnixStreamSocketDummyStatsDServer.class.getName());
2921

src/test/java/com/timgroup/statsd/UnixStreamSocketTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package com.timgroup.statsd;
22

3-
import java.net.SocketAddress;
4-
import java.util.concurrent.Callable;
53
import java.util.logging.Logger;
6-
import jnr.unixsocket.UnixSocketAddress;
74
import org.junit.After;
85
import org.junit.Assume;
96
import org.junit.Before;

0 commit comments

Comments
 (0)