NewLife/AntJob

手工拼接的 TraceId 要单独处理一下,避免在保存时出问题。
Soar360 编写于 2024-06-03 11:28:55
共计: 修改1个文件,增加6行、删除1行。
修改 +6 -1
修改 +6 -1
diff --git a/AntJob.Server/Services/JobService.cs b/AntJob.Server/Services/JobService.cs
index df7faf4..72b6989 100644
--- a/AntJob.Server/Services/JobService.cs
+++ b/AntJob.Server/Services/JobService.cs
@@ -350,7 +350,12 @@ public class JobService(AppService appService, ICacheProvider cacheProvider, ILo
         traceId = DefaultSpan.Current?.TraceId;
         if (!traceId.IsNullOrEmpty() && !tis.Contains(traceId)) tis.Add(traceId);
         task.TraceId = tis.Join(",");
-
+        while (true)
+        {
+            if (task.TraceId.Length <= JobTask._.TraceId.Length) break;
+            tis.RemoveAt(0);
+            task.TraceId = tis.Join(",");
+        }
         // 已终结的作业,汇总统计
         if (result.Status == JobStatus.完成 || result.Status == JobStatus.错误)
         {