Skip to content

Commit

Permalink
[INLONG-11529][Agent] Add exception handling for audit SDK (#11530)
Browse files Browse the repository at this point in the history
* [INLONG-11529][Agent] Add exception handling for audit SDK

* [INLONG-11529][Agent] Delete useless code

* [INLONG-11529][Agent] Print audit detail and return if args is invalid
  • Loading branch information
justinwwhuang authored Nov 22, 2024
1 parent 4f533e0 commit 7292ead
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import org.apache.inlong.audit.AuditOperator;
import org.apache.inlong.audit.entity.AuditComponent;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashSet;

import static org.apache.inlong.agent.constant.AgentConstants.AUDIT_ENABLE;
Expand All @@ -38,6 +41,8 @@
*/
public class AuditUtils {

private static final Logger LOGGER = LoggerFactory.getLogger(AuditUtils.class);
public static final int AGENT_ISOLATE_KEY = 1;
public static int AUDIT_ID_AGENT_READ_SUCCESS = 3;
public static int AUDIT_ID_AGENT_SEND_SUCCESS = 4;
public static int AUDIT_ID_AGENT_READ_FAILED = 524291;
Expand Down Expand Up @@ -90,8 +95,17 @@ public static void add(int auditID, String inlongGroupId, String inlongStreamId,
if (!IS_AUDIT) {
return;
}
AuditOperator.getInstance()
.add(auditID, DEFAULT_AUDIT_TAG, inlongGroupId, inlongStreamId, logTime, count, size, version);
if (inlongGroupId == null || inlongStreamId == null) {
LOGGER.error("invalid args inlongGroupId: {}, inlongStreamId: {}", inlongGroupId, inlongStreamId);
return;
}
try {
AuditOperator.getInstance()
.add(auditID, DEFAULT_AUDIT_TAG, inlongGroupId, inlongStreamId, logTime, count, size, version);
} catch (Throwable e) {
LOGGER.error("call audit add inlongGroupId: {}, inlongStreamId: {}, auditID {}, error", inlongGroupId,
inlongStreamId, auditID, e);
}
}

public static void add(int auditID, String inlongGroupId, String inlongStreamId,
Expand All @@ -106,6 +120,6 @@ public static void send() {
if (!IS_AUDIT) {
return;
}
AuditOperator.getInstance().flush();
AuditOperator.getInstance().flush(AGENT_ISOLATE_KEY);
}
}

This file was deleted.

0 comments on commit 7292ead

Please sign in to comment.