Skip to content

Commit 5860d2e

Browse files
committed
fix(metrics): Reduce verbosity of StatsD connection errors in non-debug mode
1 parent 16f3647 commit 5860d2e

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

products/metrics/metrics-lib/src/main/java/datadog/metrics/impl/statsd/DDAgentStatsDConnection.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,21 @@ private void doConnect() {
174174
log.debug("Max retries have been reached. Will not attempt again.");
175175
}
176176
} catch (Throwable t) {
177-
log.error("Unable to create StatsD client - {} - Will not retry", statsDAddress(), t);
177+
if (log.isDebugEnabled()) {
178+
// Display full stack traces on debug logs
179+
log.warn("Unable to create StatsD client - {} - Will not retry", statsDAddress(), t);
180+
} else {
181+
// Only report the top and root cause message
182+
Throwable rootCause = t;
183+
while (rootCause.getCause() != null) {
184+
rootCause = rootCause.getCause();
185+
}
186+
log.warn(
187+
"Unable to create StatsD client - {} - Will not retry: {}, {}",
188+
statsDAddress(),
189+
t.getMessage(),
190+
rootCause.getMessage());
191+
}
178192
}
179193
}
180194
}

0 commit comments

Comments
 (0)