Skip to content

Commit c52fc0f

Browse files
authored
sidecar: add support for udp destination (#1192)
Updates writer config to support the shorthand default `udp` destination similar to clients for other languages.
1 parent 7098256 commit c52fc0f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

spectator-reg-sidecar/src/main/java/com/netflix/spectator/sidecar/SidecarWriter.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ abstract class SidecarWriter implements Closeable {
3737
/**
3838
* Create a new writer based on a location string.
3939
*/
40+
@SuppressWarnings("PMD.AvoidUsingHardCodedIP")
4041
static SidecarWriter create(String location) {
4142
try {
4243
if ("none".equals(location)) {
@@ -49,6 +50,11 @@ static SidecarWriter create(String location) {
4950
OutputStream out = Files.newOutputStream(Paths.get(URI.create(location)));
5051
PrintStream stream = new PrintStream(out, false, "UTF-8");
5152
return new PrintStreamWriter(location, stream);
53+
} else if ("udp".equals(location)) {
54+
String host = "127.0.0.1";
55+
int port = 1234;
56+
SocketAddress address = new InetSocketAddress(host, port);
57+
return new UdpWriter(location, address);
5258
} else if (location.startsWith("udp://")) {
5359
URI uri = URI.create(location);
5460
String host = uri.getHost();

0 commit comments

Comments
 (0)