Skip to content

Commit

Permalink
修复链路统计错误
Browse files Browse the repository at this point in the history
  • Loading branch information
steden committed Oct 23, 2024
1 parent 4d54557 commit 5e8c8a8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions invokeJob.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ package fSchedule
import (
"context"
"fmt"
"sync"
"time"

"github.com/farseer-go/fSchedule/executeStatus"
"github.com/farseer-go/fs/asyncLocal"
"github.com/farseer-go/fs/container"
"github.com/farseer-go/fs/exception"
"github.com/farseer-go/fs/flog"
"github.com/farseer-go/fs/timingWheel"
"github.com/farseer-go/fs/trace"
"sync"
"time"
)

var workCount int
Expand Down Expand Up @@ -42,13 +43,11 @@ func invokeJob(clientVO ClientVO, task taskDTO) {
traceManager: container.Resolve[trace.IManager](),
}
taskList.Store(task.Id, jobContext)
// 链路追踪
entryFSchedule := jobContext.traceManager.EntryFSchedule(jobContext.Name, jobContext.Id, jobContext.Data.ToMap())

defer func() {
// 任务报告完后,移除本次任务
clientVO.report(jobContext)
taskList.Delete(task.Id)
entryFSchedule.End(nil)
asyncLocal.Release()
}()

Expand All @@ -67,6 +66,10 @@ func invokeJob(clientVO ClientVO, task taskDTO) {
workCount--
}()

// 链路追踪
entryFSchedule := jobContext.traceManager.EntryFSchedule(jobContext.Name, jobContext.Id, jobContext.Data.ToMap())
defer entryFSchedule.End(nil)

// 执行任务并拿到结果
exception.Try(func() {
// 通知调度中心,我开始执行了
Expand Down

0 comments on commit 5e8c8a8

Please sign in to comment.