22
22
import org .apache .inlong .audit .AuditOperator ;
23
23
import org .apache .inlong .audit .entity .AuditComponent ;
24
24
25
+ import org .slf4j .Logger ;
26
+ import org .slf4j .LoggerFactory ;
27
+
25
28
import java .util .HashSet ;
26
29
27
30
import static org .apache .inlong .agent .constant .AgentConstants .AUDIT_ENABLE ;
38
41
*/
39
42
public class AuditUtils {
40
43
44
+ private static final Logger LOGGER = LoggerFactory .getLogger (AuditUtils .class );
45
+ public static final int AGENT_ISOLATE_KEY = 1 ;
41
46
public static int AUDIT_ID_AGENT_READ_SUCCESS = 3 ;
42
47
public static int AUDIT_ID_AGENT_SEND_SUCCESS = 4 ;
43
48
public static int AUDIT_ID_AGENT_READ_FAILED = 524291 ;
@@ -90,8 +95,17 @@ public static void add(int auditID, String inlongGroupId, String inlongStreamId,
90
95
if (!IS_AUDIT ) {
91
96
return ;
92
97
}
93
- AuditOperator .getInstance ()
94
- .add (auditID , DEFAULT_AUDIT_TAG , inlongGroupId , inlongStreamId , logTime , count , size , version );
98
+ if (inlongGroupId == null || inlongStreamId == null ) {
99
+ LOGGER .error ("invalid args inlongGroupId: {}, inlongStreamId: {}" , inlongGroupId , inlongStreamId );
100
+ return ;
101
+ }
102
+ try {
103
+ AuditOperator .getInstance ()
104
+ .add (auditID , DEFAULT_AUDIT_TAG , inlongGroupId , inlongStreamId , logTime , count , size , version );
105
+ } catch (Throwable e ) {
106
+ LOGGER .error ("call audit add inlongGroupId: {}, inlongStreamId: {}, auditID {}, error" , inlongGroupId ,
107
+ inlongStreamId , auditID , e );
108
+ }
95
109
}
96
110
97
111
public static void add (int auditID , String inlongGroupId , String inlongStreamId ,
@@ -106,6 +120,6 @@ public static void send() {
106
120
if (!IS_AUDIT ) {
107
121
return ;
108
122
}
109
- AuditOperator .getInstance ().flush ();
123
+ AuditOperator .getInstance ().flush (AGENT_ISOLATE_KEY );
110
124
}
111
125
}
0 commit comments