Skip to content

Commit

Permalink
[INLONG-11529][Agent] Add exception handling for audit SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
justinwwhuang committed Nov 21, 2024
1 parent c99a0eb commit 87bbc71
Showing 1 changed file with 15 additions and 3 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,15 @@ 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);
}
try {
AuditOperator.getInstance()
.add(auditID, DEFAULT_AUDIT_TAG, inlongGroupId, inlongStreamId, logTime, count, size, version);
} catch (Throwable e) {
LOGGER.error("call audit add error", e);
}
}

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

0 comments on commit 87bbc71

Please sign in to comment.