-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Integrate task consumers to capture task resource information during unregister. Add consumer that logs topN expensive search tasks Co-authored-by: Sruti Parthiban <[email protected]>
- Loading branch information
1 parent
cfc1c68
commit 1b95ee0
Showing
20 changed files
with
545 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
server/src/main/java/org/opensearch/tasks/consumer/SearchShardTaskDetailsLogMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.tasks.consumer; | ||
|
||
import org.opensearch.action.search.SearchShardTask; | ||
import org.opensearch.common.logging.OpenSearchLogMessage; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Search shard task information that will be extracted from Task and converted into | ||
* format that will be logged | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public final class SearchShardTaskDetailsLogMessage extends OpenSearchLogMessage { | ||
SearchShardTaskDetailsLogMessage(SearchShardTask task) { | ||
super(prepareMap(task), message(task)); | ||
} | ||
|
||
private static Map<String, Object> prepareMap(SearchShardTask task) { | ||
Map<String, Object> messageFields = new HashMap<>(); | ||
messageFields.put("taskId", task.getId()); | ||
messageFields.put("type", task.getType()); | ||
messageFields.put("action", task.getAction()); | ||
messageFields.put("description", task.getDescription()); | ||
messageFields.put("start_time_millis", task.getStartTime()); | ||
messageFields.put("parentTaskId", task.getParentTaskId()); | ||
messageFields.put("resource_stats", task.getResourceStats()); | ||
messageFields.put("metadata", task.getTaskMetadata()); | ||
return messageFields; | ||
} | ||
|
||
// Message will be used in plaintext logs | ||
private static String message(SearchShardTask task) { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append("taskId:[") | ||
.append(task.getId()) | ||
.append("], ") | ||
.append("type:[") | ||
.append(task.getType()) | ||
.append("], ") | ||
.append("action:[") | ||
.append(task.getAction()) | ||
.append("], ") | ||
.append("description:[") | ||
.append(task.getDescription()) | ||
.append("], ") | ||
.append("start_time_millis:[") | ||
.append(task.getStartTime()) | ||
.append("], ") | ||
.append("resource_stats:[") | ||
.append(task.getResourceStats()) | ||
.append("], ") | ||
.append("metadata:[") | ||
.append(task.getTaskMetadata()) | ||
.append("]"); | ||
return sb.toString(); | ||
} | ||
} |
Oops, something went wrong.