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-9772][Agent] Increase auditing for sending exceptions and resending #9775

Merged
merged 1 commit into from
Mar 5, 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 @@ -54,8 +54,14 @@ public class AuditUtils {
public static final int AUDIT_ID_AGENT_INSTANCE_MGR_HEARTBEAT = 30009;
public static final int AUDIT_ID_AGENT_INSTANCE_HEARTBEAT = 30010;
public static final int AUDIT_ID_AGENT_SEND_FAILED_REAL_TIME = 30011;
public static final int AUDIT_ID_AGENT_ADD_INSTANCE_MEM_FAILED = 30013;
public static final int AUDIT_ID_AGENT_DEL_INSTANCE_MEM_UNUSUAL = 30014;
public static final int AUDIT_ID_AGENT_ADD_INSTANCE_MEM_FAILED = 30015;
public static final int AUDIT_ID_AGENT_TRY_SEND = 30020;
public static final int AUDIT_ID_AGENT_TRY_SEND_REAL_TIME = 30021;
public static final int AUDIT_ID_AGENT_SEND_EXCEPTION = 30022;
public static final int AUDIT_ID_AGENT_SEND_EXCEPTION_REAL_TIME = 30023;
public static final int AUDIT_ID_AGENT_RESEND = 30024;
public static final int AUDIT_ID_AGENT_RESEND_REAL_TIME = 30025;

private static boolean IS_AUDIT = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ public SenderManager(InstanceProfile profile, String inlongGroupId, String sourc
CommonConstants.PROXY_SENDER_MAX_TIMEOUT, CommonConstants.DEFAULT_PROXY_SENDER_MAX_TIMEOUT);
maxSenderRetry = profile.getInt(
CommonConstants.PROXY_SENDER_MAX_RETRY, CommonConstants.DEFAULT_PROXY_SENDER_MAX_RETRY);
retrySleepTime = profile.getLong(
retrySleepTime = agentConf.getLong(
CommonConstants.PROXY_RETRY_SLEEP, CommonConstants.DEFAULT_PROXY_RETRY_SLEEP);
isFile = profile.getBoolean(CommonConstants.PROXY_IS_FILE, CommonConstants.DEFAULT_IS_FILE);
ioThreadNum = profile.getInt(CommonConstants.PROXY_CLIENT_IO_THREAD_NUM,
CommonConstants.DEFAULT_PROXY_CLIENT_IO_THREAD_NUM);
enableBusyWait = profile.getBoolean(CommonConstants.PROXY_CLIENT_ENABLE_BUSY_WAIT,
CommonConstants.DEFAULT_PROXY_CLIENT_ENABLE_BUSY_WAIT);
batchFlushInterval = profile.getInt(PROXY_BATCH_FLUSH_INTERVAL, DEFAULT_PROXY_BATCH_FLUSH_INTERVAL);
batchFlushInterval = agentConf.getInt(PROXY_BATCH_FLUSH_INTERVAL, DEFAULT_PROXY_BATCH_FLUSH_INTERVAL);
authSecretId = agentConf.get(AGENT_MANAGER_AUTH_SECRET_ID);
authSecretKey = agentConf.get(AGENT_MANAGER_AUTH_SECRET_KEY);

Expand Down Expand Up @@ -231,13 +231,25 @@ private void sendBatchWithRetryCount(SenderMessage message, int retry) {
while (!suc) {
try {
AgentSenderCallback cb = new AgentSenderCallback(message, retry);
AuditUtils.add(AuditUtils.AUDIT_ID_AGENT_TRY_SEND, message.getGroupId(),
message.getStreamId(), message.getDataTime(), message.getMsgCnt(),
message.getTotalSize());
AuditUtils.add(AuditUtils.AUDIT_ID_AGENT_TRY_SEND_REAL_TIME, message.getGroupId(),
message.getStreamId(), AgentUtils.getCurrentTime(), message.getMsgCnt(),
message.getTotalSize());
asyncSendByMessageSender(cb, message.getDataList(), message.getGroupId(),
message.getStreamId(), message.getDataTime(), SEQUENTIAL_ID.getNextUuid(),
maxSenderTimeout, TimeUnit.SECONDS, message.getExtraMap(), proxySend);
getMetricItem(message.getGroupId(), message.getStreamId()).pluginSendCount.addAndGet(
message.getMsgCnt());
suc = true;
} catch (Exception exception) {
AuditUtils.add(AuditUtils.AUDIT_ID_AGENT_SEND_EXCEPTION, message.getGroupId(),
message.getStreamId(), message.getDataTime(), message.getMsgCnt(),
message.getTotalSize());
AuditUtils.add(AuditUtils.AUDIT_ID_AGENT_SEND_EXCEPTION_REAL_TIME, message.getGroupId(),
message.getStreamId(), AgentUtils.getCurrentTime(), message.getMsgCnt(),
message.getTotalSize());
suc = false;
if (retry > maxSenderRetry) {
if (retry % 10 == 0) {
Expand Down Expand Up @@ -276,6 +288,13 @@ private Runnable flushResendQueue() {
try {
AgentSenderCallback callback = resendQueue.poll(1, TimeUnit.SECONDS);
if (callback != null) {
SenderMessage message = callback.message;
AuditUtils.add(AuditUtils.AUDIT_ID_AGENT_RESEND, message.getGroupId(),
message.getStreamId(), message.getDataTime(), message.getMsgCnt(),
message.getTotalSize());
AuditUtils.add(AuditUtils.AUDIT_ID_AGENT_RESEND_REAL_TIME, message.getGroupId(),
message.getStreamId(), AgentUtils.getCurrentTime(), message.getMsgCnt(),
message.getTotalSize());
sendBatchWithRetryCount(callback.message, callback.retry + 1);
}
} catch (Exception ex) {
Expand Down
Loading