Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INLONG-11529][Agent] Add exception handling for audit SDK #11530

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading