Skip to content

Commit 32a83e3

Browse files
Add logging for throttling and guardrail in connector (#2725) (#2728)
Signed-off-by: b4sjoo <[email protected]> (cherry picked from commit 8f16080) Co-authored-by: Sicheng Song <[email protected]>
1 parent 66302c8 commit 32a83e3

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/remote/RemoteConnectorExecutor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,17 +196,20 @@ default void preparePayloadAndInvoke(
196196
.getTransient(ConfigConstants.OPENSEARCH_SECURITY_USER_INFO_THREAD_CONTEXT);
197197
User user = User.parse(userStr);
198198
if (getRateLimiter() != null && !getRateLimiter().request()) {
199+
getLogger().error("Request is throttled at model level.");
199200
throw new OpenSearchStatusException("Request is throttled at model level.", RestStatus.TOO_MANY_REQUESTS);
200201
} else if (user != null
201202
&& getUserRateLimiterMap() != null
202203
&& getUserRateLimiterMap().get(user.getName()) != null
203204
&& !getUserRateLimiterMap().get(user.getName()).request()) {
205+
getLogger().error("Request is throttled at user level.");
204206
throw new OpenSearchStatusException(
205207
"Request is throttled at user level. If you think there's an issue, please contact your cluster admin.",
206208
RestStatus.TOO_MANY_REQUESTS
207209
);
208210
} else {
209211
if (getMlGuard() != null && !getMlGuard().validate(payload, MLGuard.Type.INPUT, parameters)) {
212+
getLogger().error("guardrails triggered for user input");
210213
throw new IllegalArgumentException("guardrails triggered for user input");
211214
}
212215
if (getConnectorClientConfig().getMaxRetryTimes() != 0) {

0 commit comments

Comments
 (0)