@@ -188,8 +188,8 @@ class ManagedRunController {
188188
189189 console . debug ( "[ManagedRunController] Polling for latest snapshot" ) ;
190190
191- this . httpClient . sendDebugLog ( this . runFriendlyId , {
192- time : new Date ( ) ,
191+ this . sendDebugLog ( {
192+ runId : this . runFriendlyId ,
193193 message : `snapshot poll: started` ,
194194 properties : {
195195 snapshotId : this . snapshotFriendlyId ,
@@ -201,8 +201,8 @@ class ManagedRunController {
201201 if ( ! response . success ) {
202202 console . error ( "[ManagedRunController] Snapshot poll failed" , { error : response . error } ) ;
203203
204- this . httpClient . sendDebugLog ( this . runFriendlyId , {
205- time : new Date ( ) ,
204+ this . sendDebugLog ( {
205+ runId : this . runFriendlyId ,
206206 message : `snapshot poll: failed` ,
207207 properties : {
208208 snapshotId : this . snapshotFriendlyId ,
@@ -269,8 +269,8 @@ class ManagedRunController {
269269 // This should only be used when we're already executing a run. Attempt number changes are not allowed.
270270 private updateRunPhase ( run : Run , snapshot : Snapshot ) {
271271 if ( this . state . phase !== "RUN" ) {
272- this . httpClient . sendDebugLog ( run . friendlyId , {
273- time : new Date ( ) ,
272+ this . sendDebugLog ( {
273+ runId : run . friendlyId ,
274274 message : `updateRunPhase: Invalid phase for updating snapshot: ${ this . state . phase } ` ,
275275 properties : {
276276 currentPhase : this . state . phase ,
@@ -282,8 +282,8 @@ class ManagedRunController {
282282 }
283283
284284 if ( this . state . run . friendlyId !== run . friendlyId ) {
285- this . httpClient . sendDebugLog ( run . friendlyId , {
286- time : new Date ( ) ,
285+ this . sendDebugLog ( {
286+ runId : run . friendlyId ,
287287 message : `updateRunPhase: Mismatched run IDs` ,
288288 properties : {
289289 currentRunId : this . state . run . friendlyId ,
@@ -299,8 +299,8 @@ class ManagedRunController {
299299 if ( this . state . snapshot . friendlyId === snapshot . friendlyId ) {
300300 logger . debug ( "updateRunPhase: Snapshot not changed" , { run, snapshot } ) ;
301301
302- this . httpClient . sendDebugLog ( run . friendlyId , {
303- time : new Date ( ) ,
302+ this . sendDebugLog ( {
303+ runId : run . friendlyId ,
304304 message : `updateRunPhase: Snapshot not changed` ,
305305 properties : {
306306 snapshotId : snapshot . friendlyId ,
@@ -311,8 +311,8 @@ class ManagedRunController {
311311 }
312312
313313 if ( this . state . run . attemptNumber !== run . attemptNumber ) {
314- this . httpClient . sendDebugLog ( run . friendlyId , {
315- time : new Date ( ) ,
314+ this . sendDebugLog ( {
315+ runId : run . friendlyId ,
316316 message : `updateRunPhase: Attempt number changed` ,
317317 properties : {
318318 oldAttemptNumber : this . state . run . attemptNumber ?? undefined ,
@@ -418,9 +418,9 @@ class ManagedRunController {
418418 snapshotId : this . snapshotFriendlyId ,
419419 } ) ;
420420
421- this . httpClient . sendDebugLog ( run . friendlyId , {
422- time : new Date ( ) ,
423- message : ` snapshot change: missing snapshot ID` ,
421+ this . sendDebugLog ( {
422+ runId : run . friendlyId ,
423+ message : " snapshot change: missing snapshot ID" ,
424424 properties : {
425425 newSnapshotId : snapshot . friendlyId ,
426426 newSnapshotStatus : snapshot . executionStatus ,
@@ -433,9 +433,9 @@ class ManagedRunController {
433433 if ( this . snapshotFriendlyId === snapshot . friendlyId ) {
434434 console . debug ( "handleSnapshotChange: snapshot not changed, skipping" , { snapshot } ) ;
435435
436- this . httpClient . sendDebugLog ( run . friendlyId , {
437- time : new Date ( ) ,
438- message : ` snapshot change: skipping, no change` ,
436+ this . sendDebugLog ( {
437+ runId : run . friendlyId ,
438+ message : " snapshot change: skipping, no change" ,
439439 properties : {
440440 snapshotId : this . snapshotFriendlyId ,
441441 snapshotStatus : snapshot . executionStatus ,
@@ -452,8 +452,8 @@ class ManagedRunController {
452452 completedWaitpoints : completedWaitpoints . length ,
453453 } ) ;
454454
455- this . httpClient . sendDebugLog ( run . friendlyId , {
456- time : new Date ( ) ,
455+ this . sendDebugLog ( {
456+ runId : run . friendlyId ,
457457 message : `snapshot change: ${ snapshot . executionStatus } ` ,
458458 properties : {
459459 oldSnapshotId : this . snapshotFriendlyId ,
@@ -471,6 +471,15 @@ class ManagedRunController {
471471 error,
472472 } ) ;
473473
474+ this . sendDebugLog ( {
475+ runId : run . friendlyId ,
476+ message : "snapshot change: failed to update run phase" ,
477+ properties : {
478+ currentPhase : this . state . phase ,
479+ error : error instanceof Error ? error . message : String ( error ) ,
480+ } ,
481+ } ) ;
482+
474483 this . waitForNextRun ( ) ;
475484 return ;
476485 }
@@ -545,8 +554,8 @@ class ManagedRunController {
545554 error : suspendResult . error ,
546555 } ) ;
547556
548- this . httpClient . sendDebugLog ( run . friendlyId , {
549- time : new Date ( ) ,
557+ this . sendDebugLog ( {
558+ runId : run . friendlyId ,
550559 message : "checkpoint: suspend request failed" ,
551560 properties : {
552561 snapshotId : snapshot . friendlyId ,
@@ -562,8 +571,8 @@ class ManagedRunController {
562571 suspendResult : suspendResult . data ,
563572 } ) ;
564573
565- this . httpClient . sendDebugLog ( run . friendlyId , {
566- time : new Date ( ) ,
574+ this . sendDebugLog ( {
575+ runId : run . friendlyId ,
567576 message : "checkpoint: failed to suspend run" ,
568577 properties : {
569578 snapshotId : snapshot . friendlyId ,
@@ -651,9 +660,9 @@ class ManagedRunController {
651660 } catch ( error ) {
652661 console . error ( "handleSnapshotChange: unexpected error" , { error } ) ;
653662
654- this . httpClient . sendDebugLog ( run . friendlyId , {
655- time : new Date ( ) ,
656- message : ` snapshot change: unexpected error` ,
663+ this . sendDebugLog ( {
664+ runId : run . friendlyId ,
665+ message : " snapshot change: unexpected error" ,
657666 properties : {
658667 snapshotId : snapshot . friendlyId ,
659668 error : error instanceof Error ? error . message : String ( error ) ,
@@ -868,8 +877,8 @@ class ManagedRunController {
868877 } ) ;
869878
870879 if ( previousRunId ) {
871- this . httpClient . sendDebugLog ( previousRunId , {
872- time : new Date ( ) ,
880+ this . sendDebugLog ( {
881+ runId : previousRunId ,
873882 message : "warm start: received config" ,
874883 properties : {
875884 connectionTimeoutMs,
@@ -931,8 +940,8 @@ class ManagedRunController {
931940 this . socket . on ( "run:notify" , async ( { version, run } ) => {
932941 console . log ( "[ManagedRunController] Received run notification" , { version, run } ) ;
933942
934- this . httpClient . sendDebugLog ( run . friendlyId , {
935- time : new Date ( ) ,
943+ this . sendDebugLog ( {
944+ runId : run . friendlyId ,
936945 message : "run:notify received by runner" ,
937946 } ) ;
938947
@@ -951,6 +960,16 @@ class ManagedRunController {
951960 currentRunId : this . runFriendlyId ,
952961 currentSnapshotId : this . snapshotFriendlyId ,
953962 } ) ;
963+
964+ this . sendDebugLog ( {
965+ runId : run . friendlyId ,
966+ message : "run:notify: ignoring notification for different run" ,
967+ properties : {
968+ currentRunId : this . runFriendlyId ,
969+ currentSnapshotId : this . snapshotFriendlyId ,
970+ notificationRunId : run . friendlyId ,
971+ } ,
972+ } ) ;
954973 return ;
955974 }
956975
@@ -961,6 +980,16 @@ class ManagedRunController {
961980
962981 if ( ! latestSnapshot . success ) {
963982 console . error ( "Failed to get latest snapshot data" , latestSnapshot . error ) ;
983+
984+ this . sendDebugLog ( {
985+ runId : this . runFriendlyId ,
986+ message : "run:notify: failed to get latest snapshot data" ,
987+ properties : {
988+ currentRunId : this . runFriendlyId ,
989+ currentSnapshotId : this . snapshotFriendlyId ,
990+ error : latestSnapshot . error ,
991+ } ,
992+ } ) ;
964993 return ;
965994 }
966995
@@ -1126,6 +1155,28 @@ class ManagedRunController {
11261155 assertExhaustive ( attemptStatus ) ;
11271156 }
11281157
1158+ sendDebugLog ( {
1159+ runId,
1160+ message,
1161+ date,
1162+ properties,
1163+ } : {
1164+ runId : string ;
1165+ message : string ;
1166+ date ?: Date ;
1167+ properties ?: WorkloadDebugLogRequestBody [ "properties" ] ;
1168+ } ) {
1169+ this . httpClient . sendDebugLog ( runId , {
1170+ message,
1171+ time : date ?? new Date ( ) ,
1172+ properties : {
1173+ ...properties ,
1174+ runnerId : this . runnerId ,
1175+ workerName : this . workerInstanceName ,
1176+ } ,
1177+ } ) ;
1178+ }
1179+
11291180 async cancelAttempt ( runId : string ) {
11301181 logger . log ( "cancelling attempt" , { runId } ) ;
11311182
0 commit comments