kezhenxu94 commented on code in PR #10516:
URL: https://github.com/apache/dolphinscheduler/pull/10516#discussion_r902100604


##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/processor/queue/StateEventResponseService.java:
##########
@@ -109,18 +113,21 @@ protected StateEventResponseWorker() {
 
         @Override
         public void run() {
-
+            logger.info("State event loop service started");
             while (Stopper.isRunning()) {
                 try {
                     // if not task , blocking here
                     StateEvent stateEvent = eventQueue.take();
+                    MDC.put(Constants.WORKFLOW_INFO_MDC_KEY, 
String.format(Constants.WORKFLOW_TASK_HEADER_FORMAT, 
stateEvent.getProcessInstanceId(), stateEvent.getTaskInstanceId()));
                     persist(stateEvent);
+                    MDC.remove(Constants.WORKFLOW_INFO_MDC_KEY);

Review Comment:
   Move this to `finally` block?



##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java:
##########
@@ -620,28 +623,33 @@ private Constants() {
      */
     public static final String LOGIN_USER_KEY_TAB_PATH = 
"login.user.keytab.path";
 
+    public static final String WORKFLOW_INFO_MDC_KEY = "workflowInfo";
+    public static final String WORKFLOW_LOG_PREFIX_FORMAT = 
"[WorkflowInstance-%s]";

Review Comment:
   Usually we just set the workflow instance id / task instance id (without 
`[]`, `WorkflowInstanc-`, only the id like `123`), and let the users have the 
ability to configure another log pattern, we can move the pattern 
`[WorkflowInstance-%s]` to the `logback.xml`, 
(`[WorkflowInstance-%X{workflowId}]`, 
`[WorkflowInstance-%X{workflowInstanceId}]`), so when users want to collect the 
logs into their log system they can configure a more parsable log pattern.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to