@@ -383,11 +383,13 @@ func (api *API) postWorkflowJobResultHandler() Handler {
383383 if err := UnmarshalBody (r , & res ); err != nil {
384384 return sdk .WrapError (err , "postWorkflowJobResultHandler> cannot unmarshal request" )
385385 }
386- customCtx , cancel := context .WithTimeout (context . Background () , 180 * time .Second )
386+ customCtx , cancel := context .WithTimeout (ctx , 180 * time .Second )
387387 defer cancel ()
388388 dbWithCtx := api .mustDBWithCtx (customCtx )
389389
390+ _ , next := tracing .Span (ctx , "project.LoadProjectByNodeJobRunID" )
390391 proj , errP := project .LoadProjectByNodeJobRunID (ctx , dbWithCtx , api .Cache , id , getUser (ctx ), project .LoadOptions .WithVariables )
392+ next ()
391393 if errP != nil {
392394 if sdk .ErrorIs (errP , sdk .ErrNoProject ) {
393395 _ , errLn := workflow .LoadNodeJobRun (dbWithCtx , api .Cache , id )
@@ -403,15 +405,28 @@ func (api *API) postWorkflowJobResultHandler() Handler {
403405 return sdk .WrapError (errP , "postWorkflowJobResultHandler> Cannot load project from job %d" , id )
404406 }
405407
408+ tracing .Current (ctx ,
409+ tracing .Tag ("project_key" , proj .Key ),
410+ )
411+
406412 report , err := postJobResult (customCtx , api .mustDBWithCtx , api .Cache , proj , getWorker (ctx ), & res )
407413 if err != nil {
408414 return sdk .WrapError (err , "postWorkflowJobResultHandler> unable to post job result" )
409415 }
410416
411417 workflowRuns , workflowNodeRuns := workflow .GetWorkflowRunEventData (report , proj .Key )
418+
419+ if len (workflowRuns ) > 0 {
420+ tracing .Current (ctx ,
421+ tracing .Tag ("workflow" , workflowRuns [0 ].Workflow .Name ),
422+ )
423+ }
424+
412425 db := api .mustDB ()
413426
427+ _ , next = tracing .Span (ctx , "workflow.ResyncNodeRunsWithCommits" )
414428 workflow .ResyncNodeRunsWithCommits (db , api .Cache , proj , workflowNodeRuns )
429+ next ()
415430
416431 go workflow .SendEvent (db , workflowRuns , workflowNodeRuns , proj .Key )
417432
0 commit comments