|
@@ -4,6 +4,7 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
|
|
import com.tzld.commons.aliyun.log.AliyunLogManager;
|
|
|
import com.tzld.piaoquan.risk.control.service.LoghubService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.slf4j.MDC;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -52,4 +53,18 @@ public class LoghubServiceImpl implements LoghubService {
|
|
|
public void asyncSubmitLog(String project, String logStore, String topic, Map<String, Object> data) {
|
|
|
pool.execute(() -> aliyunLogManager.sendLog(project, logStore, topic, data));
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void asyncSubmitLog(String project, String logStore, String topic, Map<String, Object> data,Map<String, String> mdcContext ) {
|
|
|
+ pool.execute(() -> {
|
|
|
+ if (mdcContext != null) {
|
|
|
+ MDC.setContextMap(mdcContext); // 恢复 MDC
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ aliyunLogManager.sendLog(project, logStore, topic, data);
|
|
|
+ } finally {
|
|
|
+ MDC.clear();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|