@@ -2,6 +2,7 @@ package interpreter
22
33import (
44 "context"
5+ "encoding/json"
56 "fmt"
67 "io"
78 "net/http"
@@ -39,9 +40,9 @@ func StateApiWaitUntil(
3940 logger .Info ("StateWaitUntilActivity" , "input" , log .ToJsonAndTruncateForLogging (input ))
4041 iwfWorkerBaseUrl := urlautofix .FixWorkerUrl (input .IwfWorkerUrl )
4142
42- svcCfg := env .GetSharedConfig ()
43+ sharedCfg := env .GetSharedConfig ()
4344 apiClient := iwfidl .NewAPIClient (& iwfidl.Configuration {
44- DefaultHeader : svcCfg .Interpreter .InterpreterActivityConfig .DefaultHeaders ,
45+ DefaultHeader : sharedCfg .Interpreter .InterpreterActivityConfig .DefaultHeaders ,
4546 Servers : []iwfidl.ServerConfiguration {
4647 {
4748 URL : iwfWorkerBaseUrl ,
@@ -59,13 +60,31 @@ func StateApiWaitUntil(
5960 if input .Request .StateInput != nil && input .Request .StateInput .ExtStoreId != nil {
6061 _ , err = loadStateInputFromExternalStorage (ctx , input .Request .StateInput )
6162 if err != nil {
63+ if activityInfo .IsLocalActivity {
64+ reqBytes , _ := json .Marshal (input .Request )
65+ if sharedCfg .Interpreter .LogLocalActivityThresholdBytes > 0 {
66+ logger .Warn ("StateApiWaitUntil local activity return on error" ,
67+ "workflowId" , activityInfo .WorkflowExecution .ID ,
68+ "stateExecutionId" , input .Request .Context .GetStateExecutionId (),
69+ "payloadSize" , len (reqBytes ))
70+ }
71+ }
6272 return nil , err
6373 }
6474 }
6575
6676 // Load data attributes from external storage
6777 err = blobstore .LoadDataObjectsFromExternalStorage (ctx , input .Request .DataObjects , env .GetBlobStore ())
6878 if err != nil {
79+ if activityInfo .IsLocalActivity {
80+ reqBytes , _ := json .Marshal (input .Request )
81+ if sharedCfg .Interpreter .LogLocalActivityThresholdBytes > 0 {
82+ logger .Warn ("StateApiWaitUntil local activity return on error" ,
83+ "workflowId" , activityInfo .WorkflowExecution .ID ,
84+ "stateExecutionId" , input .Request .Context .GetStateExecutionId (),
85+ "payloadSize" , len (reqBytes ))
86+ }
87+ }
6988 return nil , err
7089 }
7190
@@ -93,6 +112,15 @@ func StateApiWaitUntil(
93112 Details : & errDetails ,
94113 },
95114 })
115+ if activityInfo .IsLocalActivity {
116+ reqBytes , _ := json .Marshal (input .Request )
117+ if sharedCfg .Interpreter .LogLocalActivityThresholdBytes > 0 {
118+ logger .Warn ("StateApiWaitUntil local activity return on error" ,
119+ "workflowId" , activityInfo .WorkflowExecution .ID ,
120+ "stateExecutionId" , input .Request .Context .GetStateExecutionId (),
121+ "payloadSize" , len (reqBytes ))
122+ }
123+ }
96124 return nil , stateStartErr
97125 }
98126
@@ -115,6 +143,15 @@ func StateApiWaitUntil(
115143 Details : & errDetails ,
116144 },
117145 })
146+ if activityInfo .IsLocalActivity {
147+ reqBytes , _ := json .Marshal (input .Request )
148+ if sharedCfg .Interpreter .LogLocalActivityThresholdBytes > 0 {
149+ logger .Warn ("StateApiWaitUntil local activity return on error" ,
150+ "workflowId" , activityInfo .WorkflowExecution .ID ,
151+ "stateExecutionId" , input .Request .Context .GetStateExecutionId (),
152+ "payloadSize" , len (reqBytes ))
153+ }
154+ }
118155 return nil , stateStartErr
119156 }
120157
@@ -125,9 +162,18 @@ func StateApiWaitUntil(
125162 resp .LocalActivityInput = composeInputForDebug (input .Request .Context .GetStateExecutionId ())
126163 }
127164
128- if env .GetSharedConfig ().ExternalStorage .Enabled {
165+ if env .GetSharedConfig ().ExternalStorage .Enabled && env . GetBlobStore () != nil {
129166 err = blobstore .WriteDataObjectsToExternalStorage (ctx , resp .UpsertDataObjects , activityInfo .WorkflowExecution .ID , env .GetSharedConfig ().ExternalStorage .ThresholdInBytes , env .GetBlobStore (), env .GetSharedConfig ().ExternalStorage .Enabled )
130167 if err != nil {
168+ if activityInfo .IsLocalActivity {
169+ reqBytes , _ := json .Marshal (input .Request )
170+ if sharedCfg .Interpreter .LogLocalActivityThresholdBytes > 0 {
171+ logger .Warn ("StateApiWaitUntil local activity return on error" ,
172+ "workflowId" , activityInfo .WorkflowExecution .ID ,
173+ "stateExecutionId" , input .Request .Context .GetStateExecutionId (),
174+ "payloadSize" , len (reqBytes ))
175+ }
176+ }
131177 return nil , err
132178 }
133179 }
@@ -143,6 +189,15 @@ func StateApiWaitUntil(
143189 EndTimestampInMs : ptr .Any (time .Now ().UnixMilli ()),
144190 SearchAttributes : searchAttributes ,
145191 })
192+ if activityInfo .IsLocalActivity {
193+ respBytes , _ := json .Marshal (resp )
194+ if threshold := sharedCfg .Interpreter .LogLocalActivityThresholdBytes ; threshold > 0 && len (respBytes ) >= threshold {
195+ logger .Warn ("StateApiWaitUntil local activity return on success" ,
196+ "workflowId" , activityInfo .WorkflowExecution .ID ,
197+ "stateExecutionId" , input .Request .Context .GetStateExecutionId (),
198+ "payloadSize" , len (respBytes ))
199+ }
200+ }
146201 return resp , nil
147202}
148203
@@ -166,9 +221,9 @@ func StateApiExecute(
166221 logger .Info ("StateExecuteActivity" , "input" , log .ToJsonAndTruncateForLogging (input ))
167222
168223 iwfWorkerBaseUrl := urlautofix .FixWorkerUrl (input .IwfWorkerUrl )
169- svcCfg := env .GetSharedConfig ()
224+ sharedCfg := env .GetSharedConfig ()
170225 apiClient := iwfidl .NewAPIClient (& iwfidl.Configuration {
171- DefaultHeader : svcCfg .Interpreter .InterpreterActivityConfig .DefaultHeaders ,
226+ DefaultHeader : sharedCfg .Interpreter .InterpreterActivityConfig .DefaultHeaders ,
172227 Servers : []iwfidl.ServerConfiguration {
173228 {
174229 URL : iwfWorkerBaseUrl ,
@@ -187,13 +242,31 @@ func StateApiExecute(
187242 if input .Request .StateInput != nil && input .Request .StateInput .ExtStoreId != nil {
188243 wholeStateInputCopy , err = loadStateInputFromExternalStorage (ctx , input .Request .StateInput )
189244 if err != nil {
245+ if activityInfo .IsLocalActivity {
246+ reqBytes , _ := json .Marshal (input .Request )
247+ if sharedCfg .Interpreter .LogLocalActivityThresholdBytes > 0 {
248+ logger .Warn ("StateApiExecute local activity return on error" ,
249+ "workflowId" , activityInfo .WorkflowExecution .ID ,
250+ "stateExecutionId" , input .Request .Context .GetStateExecutionId (),
251+ "payloadSize" , len (reqBytes ))
252+ }
253+ }
190254 return nil , err
191255 }
192256 }
193257
194258 // Load data attributes from external storage
195259 err = blobstore .LoadDataObjectsFromExternalStorage (ctx , input .Request .DataObjects , env .GetBlobStore ())
196260 if err != nil {
261+ if activityInfo .IsLocalActivity {
262+ reqBytes , _ := json .Marshal (input .Request )
263+ if sharedCfg .Interpreter .LogLocalActivityThresholdBytes > 0 {
264+ logger .Warn ("StateApiExecute local activity return on error" ,
265+ "workflowId" , activityInfo .WorkflowExecution .ID ,
266+ "stateExecutionId" , input .Request .Context .GetStateExecutionId (),
267+ "payloadSize" , len (reqBytes ))
268+ }
269+ }
197270 return nil , err
198271 }
199272
@@ -233,6 +306,15 @@ func StateApiExecute(
233306 Details : & errDetails ,
234307 },
235308 })
309+ if activityInfo .IsLocalActivity {
310+ reqBytes , _ := json .Marshal (input .Request )
311+ if sharedCfg .Interpreter .LogLocalActivityThresholdBytes > 0 {
312+ logger .Warn ("StateApiExecute local activity return on error" ,
313+ "workflowId" , activityInfo .WorkflowExecution .ID ,
314+ "stateExecutionId" , input .Request .Context .GetStateExecutionId (),
315+ "payloadSize" , len (reqBytes ))
316+ }
317+ }
236318 return nil , stateApiExecuteErr
237319 }
238320
@@ -255,6 +337,15 @@ func StateApiExecute(
255337 Details : & errDetails ,
256338 },
257339 })
340+ if activityInfo .IsLocalActivity {
341+ reqBytes , _ := json .Marshal (input .Request )
342+ if sharedCfg .Interpreter .LogLocalActivityThresholdBytes > 0 {
343+ logger .Warn ("StateApiExecute local activity return on error" ,
344+ "workflowId" , activityInfo .WorkflowExecution .ID ,
345+ "stateExecutionId" , input .Request .Context .GetStateExecutionId (),
346+ "payloadSize" , len (reqBytes ))
347+ }
348+ }
258349 return nil , stateApiExecuteErr
259350 }
260351
@@ -265,13 +356,32 @@ func StateApiExecute(
265356 resp .LocalActivityInput = composeInputForDebug (input .Request .Context .GetStateExecutionId ())
266357 }
267358
268- if env .GetSharedConfig ().ExternalStorage .Enabled {
359+ // Externalize only when enabled and blob store is available (nil when e.g. STAGING_LEVEL was empty at worker start).
360+ if env .GetSharedConfig ().ExternalStorage .Enabled && env .GetBlobStore () != nil {
269361 resp .StateDecision .NextStates , err = writeNextStateInputsToExternalStorage (ctx , resp .StateDecision .NextStates , wholeStateInputCopy , activityInfo .WorkflowExecution .ID )
270362 if err != nil {
363+ if activityInfo .IsLocalActivity {
364+ reqBytes , _ := json .Marshal (input .Request )
365+ if sharedCfg .Interpreter .LogLocalActivityThresholdBytes > 0 {
366+ logger .Warn ("StateApiExecute local activity return on error" ,
367+ "workflowId" , activityInfo .WorkflowExecution .ID ,
368+ "stateExecutionId" , input .Request .Context .GetStateExecutionId (),
369+ "payloadSize" , len (reqBytes ))
370+ }
371+ }
271372 return nil , err
272373 }
273374 err = blobstore .WriteDataObjectsToExternalStorage (ctx , resp .UpsertDataObjects , activityInfo .WorkflowExecution .ID , env .GetSharedConfig ().ExternalStorage .ThresholdInBytes , env .GetBlobStore (), env .GetSharedConfig ().ExternalStorage .Enabled )
274375 if err != nil {
376+ if activityInfo .IsLocalActivity {
377+ reqBytes , _ := json .Marshal (input .Request )
378+ if sharedCfg .Interpreter .LogLocalActivityThresholdBytes > 0 {
379+ logger .Warn ("StateApiExecute local activity return on error" ,
380+ "workflowId" , activityInfo .WorkflowExecution .ID ,
381+ "stateExecutionId" , input .Request .Context .GetStateExecutionId (),
382+ "payloadSize" , len (reqBytes ))
383+ }
384+ }
275385 return nil , err
276386 }
277387 }
@@ -287,6 +397,15 @@ func StateApiExecute(
287397 EndTimestampInMs : ptr .Any (time .Now ().UnixMilli ()),
288398 SearchAttributes : input .Request .SearchAttributes ,
289399 })
400+ if activityInfo .IsLocalActivity {
401+ respBytes , _ := json .Marshal (resp )
402+ if threshold := sharedCfg .Interpreter .LogLocalActivityThresholdBytes ; threshold > 0 && len (respBytes ) >= threshold {
403+ logger .Warn ("StateApiExecute local activity return on success" ,
404+ "workflowId" , activityInfo .WorkflowExecution .ID ,
405+ "stateExecutionId" , input .Request .Context .GetStateExecutionId (),
406+ "payloadSize" , len (respBytes ))
407+ }
408+ }
290409 return resp , nil
291410}
292411
@@ -438,11 +557,11 @@ func DumpWorkflowInternal(
438557 logger := provider .GetLogger (ctx )
439558 logger .Info ("DumpWorkflowInternalActivity" , "input" , log .ToJsonAndTruncateForLogging (req ))
440559
441- svcCfg := env .GetSharedConfig ()
442- apiAddress := svcCfg .GetApiServiceAddressWithDefault ()
560+ sharedCfg := env .GetSharedConfig ()
561+ apiAddress := sharedCfg .GetApiServiceAddressWithDefault ()
443562
444563 apiClient := iwfidl .NewAPIClient (& iwfidl.Configuration {
445- DefaultHeader : svcCfg .Interpreter .InterpreterActivityConfig .DefaultHeaders ,
564+ DefaultHeader : sharedCfg .Interpreter .InterpreterActivityConfig .DefaultHeaders ,
446565 Servers : []iwfidl.ServerConfiguration {
447566 {
448567 URL : apiAddress ,
@@ -466,14 +585,25 @@ func InvokeWorkerRpc(
466585 provider := interfaces .GetActivityProviderByType (backendType )
467586 logger := provider .GetLogger (ctx )
468587 logger .Info ("InvokeWorkerRpcActivity" , "input" , log .ToJsonAndTruncateForLogging (req ))
588+ activityInfo := provider .GetActivityInfo (ctx )
589+ sharedCfg := env .GetSharedConfig ()
469590
470- apiMaxSeconds := env . GetSharedConfig () .Api .MaxWaitSeconds
591+ apiMaxSeconds := sharedCfg .Api .MaxWaitSeconds
471592
472- resp , statusErr := rpc .InvokeWorkerRpc (ctx , rpcPrep , req , apiMaxSeconds , env .GetBlobStore (), env . GetSharedConfig () .ExternalStorage )
473- return & interfaces.InvokeRpcActivityOutput {
593+ resp , statusErr := rpc .InvokeWorkerRpc (ctx , rpcPrep , req , apiMaxSeconds , env .GetBlobStore (), sharedCfg .ExternalStorage )
594+ output := & interfaces.InvokeRpcActivityOutput {
474595 RpcOutput : resp ,
475596 StatusError : statusErr ,
476- }, nil
597+ }
598+ if activityInfo .IsLocalActivity {
599+ outputBytes , _ := json .Marshal (output )
600+ if threshold := sharedCfg .Interpreter .LogLocalActivityThresholdBytes ; threshold > 0 && len (outputBytes ) >= threshold {
601+ logger .Warn ("InvokeWorkerRpc local activity return" ,
602+ "workflowId" , activityInfo .WorkflowExecution .ID ,
603+ "payloadSize" , len (outputBytes ))
604+ }
605+ }
606+ return output , nil
477607}
478608
479609func writeNextStateInputsToExternalStorage (ctx context.Context , nextStates []iwfidl.StateMovement , currentInputCopy * iwfidl.EncodedObject , workflowId string ) ([]iwfidl.StateMovement , error ) {
0 commit comments