fix(task): attribute async task usage log to the initiating node (#5684)
Async task usage logs (LogQuotaData node dimension) were recorded under whichever node happened to poll the task to completion, not the node that submitted it. For token/adaptor-billed video tasks the pre-deduction is often 0, so the entire quota landed on the last polling node. Snapshot common.NodeName into TaskPrivateData at submit time and use it when writing the settlement consume log; fall back to the current node when empty so existing tasks stay compatible.
This commit is contained in:
+6
-1
@@ -390,6 +390,7 @@ type RecordTaskBillingLogParams struct {
|
||||
TokenId int
|
||||
Group string
|
||||
Other map[string]interface{}
|
||||
NodeName string // 任务发起节点;为空时回退当前节点
|
||||
}
|
||||
|
||||
func RecordTaskBillingLog(params RecordTaskBillingLogParams) {
|
||||
@@ -423,6 +424,10 @@ func RecordTaskBillingLog(params RecordTaskBillingLogParams) {
|
||||
common.SysLog("failed to record task billing log: " + err.Error())
|
||||
}
|
||||
if params.LogType == LogTypeConsume && common.DataExportEnabled {
|
||||
nodeName := params.NodeName
|
||||
if nodeName == "" {
|
||||
nodeName = common.NodeName
|
||||
}
|
||||
gopool.Go(func() {
|
||||
LogQuotaData(QuotaDataLogParams{
|
||||
UserID: params.UserId,
|
||||
@@ -433,7 +438,7 @@ func RecordTaskBillingLog(params RecordTaskBillingLogParams) {
|
||||
UseGroup: params.Group,
|
||||
TokenID: params.TokenId,
|
||||
ChannelID: params.ChannelId,
|
||||
NodeName: common.NodeName,
|
||||
NodeName: nodeName,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user