Skip to content

Commit 8489eb2

Browse files
committed
refactor memory logs
Signed-off-by: Xun Zhang <xunzh@amazon.com>
1 parent 2c23a4c commit 8489eb2

15 files changed

+81
-85
lines changed

memory/src/main/java/org/opensearch/ml/memory/action/conversation/CreateConversationTransportAction.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ protected void doExecute(Task task, CreateConversationRequest request, ActionLis
8686
try (ThreadContext.StoredContext context = client.threadPool().getThreadContext().newStoredContext(true)) {
8787
ActionListener<CreateConversationResponse> internalListener = ActionListener.runBefore(actionListener, () -> context.restore());
8888
ActionListener<String> al = ActionListener.wrap(r -> { internalListener.onResponse(new CreateConversationResponse(r)); }, e -> {
89-
log.error("Failed to create new conversation with name " + request.getName(), e);
89+
log.error("Failed to create new memory with name " + request.getName(), e);
9090
internalListener.onFailure(e);
9191
});
9292

@@ -96,7 +96,7 @@ protected void doExecute(Task task, CreateConversationRequest request, ActionLis
9696
cmHandler.createConversation(name, applicationType, al);
9797
}
9898
} catch (Exception e) {
99-
log.error("Failed to create new conversation with name " + request.getName(), e);
99+
log.error("Failed to create new memory with name " + request.getName(), e);
100100
actionListener.onFailure(e);
101101
}
102102
}

memory/src/main/java/org/opensearch/ml/memory/action/conversation/CreateInteractionTransportAction.java

+5-9
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,15 @@ protected void doExecute(Task task, CreateInteractionRequest request, ActionList
9898
ActionListener<CreateInteractionResponse> internalListener = ActionListener.runBefore(actionListener, () -> context.restore());
9999
ActionListener<String> al = ActionListener.wrap(iid -> {
100100
cmHandler.updateConversation(cid, new HashMap<>(), getUpdateResponseListener(cid, iid, internalListener));
101+
log.info("Updating the memory {} after the message {} is created", cid, iid);
101102
}, e -> { internalListener.onFailure(e); });
102103
if (parintIid == null || traceNumber == null) {
103104
cmHandler.createInteraction(cid, inp, prompt, rsp, ogn, additionalInfo, al);
104105
} else {
105106
cmHandler.createInteraction(cid, inp, prompt, rsp, ogn, additionalInfo, al, parintIid, traceNumber);
106107
}
107108
} catch (Exception e) {
108-
log.error("Failed to create interaction for conversation " + cid, e);
109+
log.error("Failed to create message for memory " + cid, e);
109110
actionListener.onFailure(e);
110111
}
111112
}
@@ -117,21 +118,16 @@ private ActionListener<UpdateResponse> getUpdateResponseListener(
117118
) {
118119
return ActionListener.wrap(updateResponse -> {
119120
if (updateResponse != null && updateResponse.getResult() == DocWriteResponse.Result.UPDATED) {
120-
log
121-
.debug(
122-
"Successfully updated the Conversation with ID: {} after interaction {} is created",
123-
conversationId,
124-
interactionId
125-
);
121+
log.debug("Successfully updated the memory with ID: {} after message {} is created", conversationId, interactionId);
126122
actionListener.onResponse(new CreateInteractionResponse(interactionId));
127123
} else {
128-
log.error("Failed to update the Conversation with ID: {} after interaction {} is created", conversationId, interactionId);
124+
log.error("Failed to update the memory with ID: {} after message {} is created", conversationId, interactionId);
129125
actionListener.onResponse(new CreateInteractionResponse(interactionId));
130126
}
131127
}, exception -> {
132128
log
133129
.error(
134-
"Failed to update Conversation with ID {} after interaction {} is created. Details: {}",
130+
"Failed to update memory with ID {} after message {} is created. Details: {}",
135131
conversationId,
136132
interactionId,
137133
exception

memory/src/main/java/org/opensearch/ml/memory/action/conversation/DeleteConversationTransportAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void doExecute(Task task, DeleteConversationRequest request, ActionListen
9090
}, e -> { internalListener.onFailure(e); });
9191
cmHandler.deleteConversation(conversationId, al);
9292
} catch (Exception e) {
93-
log.error("Failed to delete conversation " + conversationId, e);
93+
log.error("Failed to delete memory " + conversationId, e);
9494
listener.onFailure(e);
9595
}
9696
}

memory/src/main/java/org/opensearch/ml/memory/action/conversation/GetConversationTransportAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void doExecute(Task task, GetConversationRequest request, ActionListener<
9090
}, e -> { internalListener.onFailure(e); });
9191
cmHandler.getConversation(conversationId, al);
9292
} catch (Exception e) {
93-
log.error("Failed to get Conversation " + conversationId, e);
93+
log.error("Failed to get memory " + conversationId, e);
9494
actionListener.onFailure(e);
9595
}
9696

memory/src/main/java/org/opensearch/ml/memory/action/conversation/GetConversationsTransportAction.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ public void doExecute(Task task, GetConversationsRequest request, ActionListener
9292
internalListener
9393
.onResponse(new GetConversationsResponse(conversations, from + maxResults, conversations.size() == maxResults));
9494
}, e -> {
95-
log.error("Failed to get conversations", e);
95+
log.error("Failed to get memories", e);
9696
internalListener.onFailure(e);
9797
});
9898
cmHandler.getConversations(from, maxResults, al);
9999
} catch (Exception e) {
100-
log.error("Failed to get conversations", e);
100+
log.error("Failed to get memories", e);
101101
actionListener.onFailure(e);
102102
}
103103
}

memory/src/main/java/org/opensearch/ml/memory/action/conversation/GetInteractionTransportAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void doExecute(Task task, GetInteractionRequest request, ActionListener<G
8787
}, e -> { internalListener.onFailure(e); });
8888
cmHandler.getInteraction(interactionId, al);
8989
} catch (Exception e) {
90-
log.error("Failed to get interaction " + interactionId, e);
90+
log.error("Failed to get message " + interactionId, e);
9191
actionListener.onFailure(e);
9292
}
9393
}

memory/src/main/java/org/opensearch/ml/memory/action/conversation/GetInteractionsTransportAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void doExecute(Task task, GetInteractionsRequest request, ActionListener<
9494
}, e -> { internalListener.onFailure(e); });
9595
cmHandler.getInteractions(request.getConversationId(), from, maxResults, al);
9696
} catch (Exception e) {
97-
log.error("Failed to get interactions for conversation " + request.getConversationId(), e);
97+
log.error("Failed to get messages for memory " + request.getConversationId(), e);
9898
actionListener.onFailure(e);
9999
}
100100

memory/src/main/java/org/opensearch/ml/memory/action/conversation/GetTracesTransportAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void doExecute(Task task, GetTracesRequest request, ActionListener<GetTra
5757
}, e -> { internalListener.onFailure(e); });
5858
cmHandler.getTraces(request.getInteractionId(), from, maxResults, al);
5959
} catch (Exception e) {
60-
log.error("Failed to get traces for conversation " + request.getInteractionId(), e);
60+
log.error("Failed to get traces for message " + request.getInteractionId(), e);
6161
actionListener.onFailure(e);
6262
}
6363
}

memory/src/main/java/org/opensearch/ml/memory/action/conversation/SearchConversationsTransportAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void doExecute(Task task, SearchRequest request, ActionListener<SearchRes
8484
ActionListener<SearchResponse> internalListener = ActionListener.runBefore(actionListener, () -> context.restore());
8585
cmHandler.searchConversations(request, internalListener);
8686
} catch (Exception e) {
87-
log.error("Failed to search conversations", e);
87+
log.error("Failed to search memories", e);
8888
actionListener.onFailure(e);
8989
}
9090
}

memory/src/main/java/org/opensearch/ml/memory/action/conversation/SearchInteractionsTransportAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void doExecute(Task task, SearchInteractionsRequest request, ActionListen
8383
ActionListener<SearchResponse> internalListener = ActionListener.runBefore(actionListener, () -> context.restore());
8484
cmHandler.searchInteractions(request.getConversationId(), request, internalListener);
8585
} catch (Exception e) {
86-
log.error("Failed to search conversations", e);
86+
log.error("Failed to search memories", e);
8787
actionListener.onFailure(e);
8888
}
8989
}

memory/src/main/java/org/opensearch/ml/memory/action/conversation/UpdateConversationTransportAction.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ protected void doExecute(Task task, ActionRequest request, ActionListener<Update
7171

7272
cmHandler.updateConversation(conversationId, updateContent, getUpdateResponseListener(conversationId, listener, context));
7373
} catch (Exception e) {
74-
log.error("Failed to update Conversation " + conversationId, e);
74+
log.error("Failed to update Memory " + conversationId, e);
7575
listener.onFailure(e);
7676
}
7777
}
@@ -84,14 +84,14 @@ private ActionListener<UpdateResponse> getUpdateResponseListener(
8484
) {
8585
return ActionListener.runBefore(ActionListener.wrap(updateResponse -> {
8686
if (updateResponse != null && updateResponse.getResult() == DocWriteResponse.Result.UPDATED) {
87-
log.info("Successfully updated the Conversation with ID: {}", conversationId);
87+
log.info("Successfully updated the Memory with ID: {}", conversationId);
8888
actionListener.onResponse(updateResponse);
8989
} else {
90-
log.info("Failed to update the Conversation with ID: {}", conversationId);
90+
log.info("Failed to update the Memory with ID: {}", conversationId);
9191
actionListener.onResponse(updateResponse);
9292
}
9393
}, exception -> {
94-
log.error("Failed to update ML Conversation with ID " + conversationId, exception);
94+
log.error("Failed to update ML Memory with ID " + conversationId, exception);
9595
actionListener.onFailure(exception);
9696
}), context::restore);
9797
}

memory/src/main/java/org/opensearch/ml/memory/action/conversation/UpdateInteractionTransportAction.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ protected void doExecute(Task task, ActionRequest request, ActionListener<Update
6969

7070
cmHandler.updateInteraction(interactionId, updateContent, getUpdateResponseListener(interactionId, listener, context));
7171
} catch (Exception e) {
72-
log.error("Failed to update Interaction " + interactionId, e);
72+
log.error("Failed to update Message " + interactionId, e);
7373
listener.onFailure(e);
7474
}
7575
}
@@ -81,14 +81,14 @@ private ActionListener<UpdateResponse> getUpdateResponseListener(
8181
) {
8282
return ActionListener.runBefore(ActionListener.wrap(updateResponse -> {
8383
if (updateResponse != null && updateResponse.getResult() == DocWriteResponse.Result.UPDATED) {
84-
log.info("Successfully updated the interaction with ID: {}", interactionId);
84+
log.info("Successfully updated the Message with ID: {}", interactionId);
8585
actionListener.onResponse(updateResponse);
8686
} else {
87-
log.info("Failed to update the interaction with ID: {}", interactionId);
87+
log.info("Failed to update the Message with ID: {}", interactionId);
8888
actionListener.onResponse(updateResponse);
8989
}
9090
}, exception -> {
91-
log.error("Failed to update ML interaction with ID " + interactionId, exception);
91+
log.error("Failed to update ML Message with ID " + interactionId, exception);
9292
actionListener.onFailure(exception);
9393
}), context::restore);
9494
}

0 commit comments

Comments
 (0)