Skip to content

Allow dogstatsd port to be configurable with DD_DOGSTATSD_PORT #8693

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

Merged
merged 2 commits into from
Apr 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package datadog.communication.monitor;

import static datadog.trace.api.ConfigDefaults.DEFAULT_DOGSTATSD_PORT;
import static datadog.trace.bootstrap.instrumentation.api.WriterConstants.LOGGING_WRITER_TYPE;

import datadog.trace.api.Config;
Expand All @@ -22,7 +21,8 @@ public static StatsDClientManager statsDClientManager() {
return INSTANCE;
}

private static final AtomicInteger defaultStatsDPort = new AtomicInteger(DEFAULT_DOGSTATSD_PORT);
private static final AtomicInteger defaultStatsDPort =
new AtomicInteger(Config.get().getDogsStatsDPort());

public static void setDefaultStatsDPort(final int newPort) {
if (newPort > 0 && defaultStatsDPort.getAndSet(newPort) != newPort) {
Expand Down
7 changes: 7 additions & 0 deletions internal-api/src/main/java/datadog/trace/api/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ public static String getHostName() {
private final List<String> traceAgentArgs;
private final String dogStatsDPath;
private final List<String> dogStatsDArgs;
private final int dogStatsDPort;

private String env;
private String version;
Expand Down Expand Up @@ -1084,6 +1085,8 @@ private Config(final ConfigProvider configProvider, final InstrumenterConfig ins
configProvider.getInteger(
DOGSTATSD_START_DELAY, DEFAULT_DOGSTATSD_START_DELAY, JMX_FETCH_START_DELAY);

dogStatsDPort = configProvider.getInteger(DOGSTATSD_PORT, DEFAULT_DOGSTATSD_PORT);

statsDClientQueueSize = configProvider.getInteger(STATSD_CLIENT_QUEUE_SIZE);
statsDClientSocketBuffer = configProvider.getInteger(STATSD_CLIENT_SOCKET_BUFFER);
statsDClientSocketTimeout = configProvider.getInteger(STATSD_CLIENT_SOCKET_TIMEOUT);
Expand Down Expand Up @@ -3528,6 +3531,10 @@ public List<String> getDogStatsDArgs() {
return dogStatsDArgs;
}

public int getDogsStatsDPort() {
return dogStatsDPort;
}

public String getConfigFileStatus() {
return configFileStatus;
}
Expand Down