Skip to content

Commit 133f99b

Browse files
committed
Refine error messages and remove redundant logging
Signed-off-by: shuangli-z <[email protected]>
1 parent f6d4830 commit 133f99b

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

common/src/main/java/org/opensearch/ml/common/indexInsight/FieldDescriptionTask.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,14 @@ public void runTask(String tenantId, ActionListener<IndexInsight> listener) {
5252
client,
5353
tenantId,
5454
ActionListener
55-
.wrap(agentId -> { batchProcessFields(statisticalContentMap, agentId, tenantId, listener); }, listener::onFailure)
55+
.wrap(
56+
agentId -> { batchProcessFields(statisticalContentMap, agentId, tenantId, listener); },
57+
e -> handleError("Failed to get agent ID from ML config", e, tenantId, listener)
58+
)
5659
);
57-
}, e -> handleError("Failed to get statistical content for index {}", e, tenantId, listener)));
60+
}, e -> handleError("Failed to get statistical content for index: {}", e, tenantId, listener)));
5861
} catch (Exception e) {
59-
handleError("Failed to execute field description task for index {}", e, tenantId, listener);
62+
handleError("Failed to execute field description task for index: {}", e, tenantId, listener);
6063
}
6164
}
6265

@@ -170,7 +173,7 @@ private void batchProcessFields(
170173
saveResult("", tenantId, ActionListener.wrap(insight -> {
171174
log.info("Empty field description completed for: {}", sourceIndex);
172175
listener.onResponse(insight);
173-
}, e -> handleError("Failed to save empty field description result for index {}", e, tenantId, listener)));
176+
}, e -> handleError("Failed to save empty field description result for index: {}", e, tenantId, listener)));
174177
return;
175178
}
176179

@@ -195,13 +198,12 @@ private void batchProcessFields(
195198
saveResult(gson.toJson(resultsMap), tenantId, ActionListener.wrap(insight -> {
196199
log.info("Field description completed for: {}", sourceIndex);
197200
listener.onResponse(insight);
198-
}, e -> handleError("Failed to save field description result for index {}", e, tenantId, listener)));
201+
}, e -> handleError("Failed to save field description result for index: {}", e, tenantId, listener)));
199202
} else {
200-
handleError("Batch processing failed for index {}", new Exception("Batch processing failed"), tenantId, listener);
203+
handleError("Batch processing failed for index: {}", new Exception("Batch processing failed"), tenantId, listener);
201204
}
202205
} catch (InterruptedException e) {
203-
log.error("Batch processing interrupted for index: {}", sourceIndex);
204-
handleError("Batch processing interrupted for index {}", e, tenantId, listener);
206+
handleError("Batch processing interrupted for index: {}", e, tenantId, listener);
205207
}
206208
}
207209

common/src/main/java/org/opensearch/ml/common/indexInsight/LogRelatedIndexCheckTask.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,15 @@ public void runTask(String tenantId, ActionListener<IndexInsight> listener) {
9292
getAgentIdToRun(
9393
client,
9494
tenantId,
95-
ActionListener.wrap(agentId -> performLogAnalysis(agentId, tenantId, listener), listener::onFailure)
95+
ActionListener
96+
.wrap(
97+
agentId -> performLogAnalysis(agentId, tenantId, listener),
98+
e -> handleError("Failed to get agent ID from ML config", e, tenantId, listener)
99+
)
96100
);
97101
}, listener::onFailure));
98102
} catch (Exception e) {
99-
handleError("Failed log related check for {}", e, tenantId, listener);
103+
handleError("Failed log related check for index: {}", e, tenantId, listener);
100104
}
101105
}
102106

@@ -136,13 +140,13 @@ private void performLogAnalysis(String agentId, String tenantId, ActionListener<
136140
try {
137141
Map<String, Object> parsed = parseCheckResponse(response);
138142
saveResult(MAPPER.writeValueAsString(parsed), tenantId, ActionListener.wrap(insight -> {
139-
log.info("Log related check completed for index {}", sourceIndex);
143+
log.info("Log related check completed for index: {}", sourceIndex);
140144
listener.onResponse(insight);
141-
}, e -> handleError("Failed to save log related check result for index {}", e, tenantId, listener)));
145+
}, e -> handleError("Failed to save log related check result for index: {}", e, tenantId, listener)));
142146
} catch (Exception e) {
143-
handleError("Error parsing response of log related check for {}", e, tenantId, listener);
147+
handleError("Error parsing response of log related check for index: {}", e, tenantId, listener);
144148
}
145-
}, e -> handleError("Failed to call LLM for log related check: {}", e, tenantId, listener)));
149+
}, e -> handleError("Failed to call LLM for log related check for index: {}", e, tenantId, listener)));
146150
}
147151

148152
private Map<String, Object> parseCheckResponse(String resp) {

common/src/main/java/org/opensearch/ml/common/indexInsight/StatisticalDataTask.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public void runTask(String tenantId, ActionListener<IndexInsight> listener, bool
101101
try {
102102
collectStatisticalData(tenantId, shouldStore, listener);
103103
} catch (Exception e) {
104-
handleError("Failed to execute statistical data task for index {}", e, tenantId, listener, shouldStore);
104+
handleError("Failed to execute statistical data task for index: {}", e, tenantId, listener, shouldStore);
105105
}
106106
}
107107

@@ -364,7 +364,7 @@ private Map<String, Object> parseSearchResult(
364364
} catch (Exception e) {
365365
log
366366
.error(
367-
"Failed to parse aggregation result from DSL in statistical index insight for index name: {}",
367+
"Failed to parse aggregation result from DSL in statistical index insight for index: {}",
368368
sourceIndex,
369369
e
370370
);

0 commit comments

Comments
 (0)