Skip to content

Commit c68b54c

Browse files
authored
Error Logs Remediation 2 (#9467)
1 parent 2cfe50a commit c68b54c

File tree

17 files changed

+58
-79
lines changed

17 files changed

+58
-79
lines changed

communication/src/main/java/datadog/communication/http/HttpRetryPolicy.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,9 @@ private long getRateLimitResetTime(okhttp3.Response response) {
123123
return Long.parseLong(rateLimitHeader);
124124
} catch (NumberFormatException e) {
125125
log.error(
126-
"Could not parse "
127-
+ X_RATELIMIT_RESET_HTTP_HEADER
128-
+ " header contents: "
129-
+ rateLimitHeader,
126+
"Could not parse {} header contents: {}",
127+
X_RATELIMIT_RESET_HTTP_HEADER,
128+
rateLimitHeader,
130129
e);
131130
return RATE_LIMIT_RESET_TIME_UNDEFINED;
132131
}

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/CiVisibilityServices.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,9 @@ static Map<String, String> getRemoteEnvironment(String url, String key, OkHttpCl
180180
return adapter.fromJson(response.body().source());
181181
} else {
182182
logger.warn(
183-
"Could not get remote CI environment (HTTP code "
184-
+ response.code()
185-
+ ")"
186-
+ (response.body() != null ? ": " + response.body().string() : ""));
183+
"Could not get remote CI environment (HTTP code {}) {}",
184+
response.code(),
185+
response.body() != null ? ": " + response.body().string() : "");
187186
return Collections.emptyMap();
188187
}
189188

dd-java-agent/agent-crashtracking/src/main/java/datadog/crashtracking/CrashUploaderScriptInitializer.java

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,28 +67,21 @@ private static boolean copyCrashUploaderScript(
6767
} catch (UnsupportedOperationException e) {
6868
LOG.warn(
6969
SEND_TELEMETRY,
70-
"Unsupported permissions '"
71-
+ RWXRWXRWX
72-
+ "' for "
73-
+ scriptDirectory
74-
+ ". "
75-
+ SETUP_FAILURE_MESSAGE);
70+
"Unsupported permissions '" + RWXRWXRWX + "' for {}. " + SETUP_FAILURE_MESSAGE,
71+
scriptDirectory);
7672
return false;
7773
} catch (FileAlreadyExistsException ignored) {
7874
// can be safely ignored; if the folder exists we will just reuse it
7975
if (!Files.isWritable(scriptDirectory)) {
8076
LOG.warn(
81-
SEND_TELEMETRY,
82-
"Read only directory " + scriptDirectory + ". " + SETUP_FAILURE_MESSAGE);
77+
SEND_TELEMETRY, "Read only directory {}. " + SETUP_FAILURE_MESSAGE, scriptDirectory);
8378
return false;
8479
}
8580
} catch (IOException e) {
8681
LOG.warn(
8782
SEND_TELEMETRY,
88-
"Failed to create writable crash tracking script folder "
89-
+ scriptDirectory
90-
+ ". "
91-
+ SETUP_FAILURE_MESSAGE);
83+
"Failed to create writable crash tracking script folder {}. " + SETUP_FAILURE_MESSAGE,
84+
scriptDirectory);
9285
return false;
9386
}
9487
try {
@@ -97,7 +90,8 @@ private static boolean copyCrashUploaderScript(
9790
} catch (IOException e) {
9891
LOG.warn(
9992
SEND_TELEMETRY,
100-
"Failed to copy crash tracking script " + scriptPath + ". " + SETUP_FAILURE_MESSAGE);
93+
"Failed to copy crash tracking script {}. " + SETUP_FAILURE_MESSAGE,
94+
scriptPath);
10195
return false;
10296
}
10397
return true;

dd-java-agent/agent-crashtracking/src/main/java/datadog/crashtracking/Initializer.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,12 @@ static void writeConfig(Path scriptPath, String... entries) {
175175
LOG.debug("Deleting config file: {}", cfgPath);
176176
Files.deleteIfExists(cfgPath);
177177
} catch (IOException e) {
178-
LOG.warn(SEND_TELEMETRY, "Failed deleting config file: " + cfgPath, e);
178+
LOG.warn(SEND_TELEMETRY, "Failed deleting config file: {}", cfgPath, e);
179179
}
180180
}));
181181
LOG.debug("Config file written: {}", cfgPath);
182182
} catch (IOException e) {
183-
LOG.warn(SEND_TELEMETRY, "Failed writing config file: " + cfgPath);
183+
LOG.warn(SEND_TELEMETRY, "Failed writing config file: {}", cfgPath);
184184
try {
185185
Files.deleteIfExists(cfgPath);
186186
} catch (IOException ignored) {
@@ -348,10 +348,8 @@ private static void logInitializationError(String msg, Throwable t) {
348348
} else {
349349
LOG.warn(
350350
SEND_TELEMETRY,
351-
msg
352-
+ " ["
353-
+ t.getMessage()
354-
+ "] (Change the logging level to debug to see the full stacktrace)");
351+
msg + " [{}] (Change the logging level to debug to see the full stacktrace)",
352+
t.getMessage());
355353
}
356354
}
357355
}

dd-java-agent/agent-crashtracking/src/main/java/datadog/crashtracking/OOMENotifierScriptInitializer.java

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ static void initialize(String onOutOfMemoryVal) {
4343
if (scriptPath == null) {
4444
LOG.error(
4545
SEND_TELEMETRY,
46-
"OOME notifier script value ("
47-
+ onOutOfMemoryVal
48-
+ ") does not follow the expected format: <path>/dd_oome_notifier.(sh|bat) %p. OOME tracking is disabled.");
46+
"OOME notifier script value ({}) does not follow the expected format: <path>/dd_oome_notifier.(sh|bat) %p. OOME tracking is disabled.",
47+
onOutOfMemoryVal);
4948
return;
5049
}
5150
String agentJar = findAgentJar();
@@ -86,9 +85,8 @@ private static boolean copyOOMEscript(Path scriptPath) {
8685
if (!Files.isWritable(scriptDirectory)) {
8786
LOG.warn(
8887
SEND_TELEMETRY,
89-
"Read only directory "
90-
+ scriptDirectory
91-
+ ". OOME notification will not work properly.");
88+
"Read only directory {}. OOME notification will not work properly.",
89+
scriptDirectory);
9290
return false;
9391
}
9492
} else {
@@ -97,22 +95,19 @@ private static boolean copyOOMEscript(Path scriptPath) {
9795
} catch (UnsupportedOperationException e) {
9896
LOG.warn(
9997
SEND_TELEMETRY,
100-
"Unsupported permissions '"
98+
"Unsupported permissions '{"
10199
+ RWXRWXRWX
102-
+ "' for "
103-
+ scriptDirectory
104-
+ ". OOME notification will not work properly.");
100+
+ "' for {}. OOME notification will not work properly.",
101+
scriptDirectory);
105102
return false;
106103
} catch (FileAlreadyExistsException ignored) {
107-
LOG.warn(
108-
SEND_TELEMETRY, "Path " + scriptDirectory + " already exists and is not a directory.");
104+
LOG.warn(SEND_TELEMETRY, "Path {} already exists and is not a directory.", scriptDirectory);
109105
return false;
110106
} catch (IOException e) {
111107
LOG.warn(
112108
SEND_TELEMETRY,
113-
"Failed to create writable OOME script folder "
114-
+ scriptDirectory
115-
+ ". OOME notification will not work properly.");
109+
"Failed to create writable OOME script folder {}. OOME notification will not work properly.",
110+
scriptDirectory);
116111
return false;
117112
}
118113

@@ -125,9 +120,8 @@ private static boolean copyOOMEscript(Path scriptPath) {
125120
} catch (IOException e) {
126121
LOG.warn(
127122
SEND_TELEMETRY,
128-
"Failed to copy OOME script "
129-
+ scriptPath
130-
+ ". OOME notification will not work properly.");
123+
"Failed to copy OOME script {}. OOME notification will not work properly.",
124+
scriptPath);
131125
return false;
132126
}
133127
return true;

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/agent/ConfigurationUpdater.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ private void storeDebuggerDefinitions(ConfigurationComparer changes) {
233233
public ProbeImplementation resolve(String encodedProbeId) {
234234
ProbeDefinition definition = appliedDefinitions.get(encodedProbeId);
235235
if (definition == null) {
236-
LOGGER.warn(SEND_TELEMETRY, "Cannot resolve probe id=" + encodedProbeId);
236+
LOGGER.warn(SEND_TELEMETRY, "Cannot resolve probe id={}", encodedProbeId);
237237
}
238238
return definition;
239239
}

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/agent/ThirdPartyLibraries.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public Set<String> getThirdPartyLibraries(Config config) {
5151
excludes.addAll(defaults.getPrefixes());
5252
return excludes;
5353
} catch (Exception e) {
54-
LOGGER.error("Failed reading " + FILE_NAME + ". Treating all classes as third party.", e);
54+
LOGGER.error("Failed reading {}. Treating all classes as third party.", FILE_NAME, e);
5555
return getExcludeAll();
5656
}
5757
}

dd-java-agent/agent-llmobs/src/main/java/datadog/trace/llmobs/EvalProcessingWorker.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,9 @@ protected void flushIfNecessary() {
177177
this.buffer.clear();
178178
} else {
179179
log.error(
180-
"Could not submit eval metrics (HTTP code "
181-
+ response.code()
182-
+ ")"
183-
+ (response.body() != null ? ": " + response.body().string() : ""));
180+
"Could not submit eval metrics (HTTP code {}) {}",
181+
response.code(),
182+
response.body() != null ? response.body().string() : "");
184183
}
185184
} catch (Exception e) {
186185
log.error("Could not submit eval metrics", e);

dd-java-agent/agent-profiling/src/main/java/com/datadog/profiling/agent/CompositeController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public static Controller build(ConfigProvider provider, ControllerContext contex
156156
Class.forName("com.oracle.jrockit.jfr.Producer");
157157
controllers.add(OracleJdkController.instance(provider));
158158
} catch (Throwable t) {
159-
log.debug(SEND_TELEMETRY, "Failed to load oracle profiler: " + t.getMessage(), t);
159+
log.debug(SEND_TELEMETRY, "Failed to load oracle profiler: {}", t.getMessage(), t);
160160
}
161161
}
162162
if (!isOracleJDK8) {

dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/AgentCLI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private static void unzipJar(Consumer<File> invoker, File file) throws IOExcepti
164164
log.debug("Adding new jar: {}", temp.getAbsolutePath());
165165
recursiveDependencySearch(invoker, temp);
166166
if (!temp.delete()) {
167-
log.error("Error deleting temp file:{}", temp.getAbsolutePath());
167+
log.error("Error deleting temp file: {}", temp.getAbsolutePath());
168168
}
169169
} catch (Exception ex) {
170170
log.error("Error unzipping file", ex);

0 commit comments

Comments
 (0)