@@ -258,21 +258,21 @@ func isDecisionEvent(eventType s.EventType) bool {
258
258
259
259
// NextDecisionEvents returns events that there processed as new by the next decision.
260
260
// TODO(maxim): Refactor to return a struct instead of multiple parameters
261
- func (eh * history ) NextDecisionEvents () (result []* s.HistoryEvent , markers []* s.HistoryEvent , binaryChecksum * string , historySize int , err error ) {
261
+ func (eh * history ) NextDecisionEvents () (result []* s.HistoryEvent , markers []* s.HistoryEvent , binaryChecksum * string , err error ) {
262
262
if eh .next == nil {
263
- eh .next , _ , historySize , err = eh .nextDecisionEvents ()
263
+ eh .next , _ , err = eh .nextDecisionEvents ()
264
264
if err != nil {
265
- return result , markers , eh .binaryChecksum , historySize , err
265
+ return result , markers , eh .binaryChecksum , err
266
266
}
267
267
}
268
268
269
269
result = eh .next
270
270
checksum := eh .binaryChecksum
271
271
if len (result ) > 0 {
272
- eh .next , markers , historySize , err = eh .nextDecisionEvents ()
272
+ eh .next , markers , err = eh .nextDecisionEvents ()
273
273
}
274
274
275
- return result , markers , checksum , historySize , err
275
+ return result , markers , checksum , err
276
276
}
277
277
278
278
func (eh * history ) HasNextDecisionEvents () bool {
@@ -304,13 +304,12 @@ func (eh *history) verifyAllEventsProcessed() error {
304
304
return nil
305
305
}
306
306
307
- func (eh * history ) nextDecisionEvents () (nextEvents []* s.HistoryEvent , markers []* s.HistoryEvent , historySizeEstimation int , err error ) {
307
+ func (eh * history ) nextDecisionEvents () (nextEvents []* s.HistoryEvent , markers []* s.HistoryEvent , err error ) {
308
308
if eh .currentIndex == len (eh .loadedEvents ) && ! eh .hasMoreEvents () {
309
- eh .eventsHandler .logger .Info ("Returning 0 for historySizeEstimation since none will be processed" )
310
309
if err := eh .verifyAllEventsProcessed (); err != nil {
311
- return nil , nil , 0 , err
310
+ return nil , nil , err
312
311
}
313
- return []* s.HistoryEvent {}, []* s.HistoryEvent {}, 0 , nil
312
+ return []* s.HistoryEvent {}, []* s.HistoryEvent {}, nil
314
313
}
315
314
316
315
// Process events
@@ -371,141 +370,7 @@ OrderEvents:
371
370
eh .loadedEvents = eh .loadedEvents [eh .currentIndex :]
372
371
eh .currentIndex = 0
373
372
374
- // estimate history size for nextEvents and markers
375
- //historySizeEstimation += eh.estimateHistorySize(nextEvents)
376
- //historySizeEstimation += eh.estimateHistorySize(markers)
377
- //
378
- //eh.eventsHandler.logger.Info(fmt.Sprintf("Returning historySizeEstimation not zero of %d", historySizeEstimation))
379
-
380
- return nextEvents , markers , historySizeEstimation , nil
381
- }
382
-
383
- func (eh * history ) estimateHistorySize (events []* s.HistoryEvent ) int {
384
- sum := 0
385
- for _ , e := range events {
386
- eventSum := historySizeEstimationOffset
387
- switch e .GetEventType () {
388
- case s .EventTypeWorkflowExecutionStarted :
389
- if e .WorkflowExecutionStartedEventAttributes != nil {
390
- eventSum += len (e .WorkflowExecutionStartedEventAttributes .Input )
391
- eventSum += len (e .WorkflowExecutionStartedEventAttributes .ContinuedFailureDetails )
392
- eventSum += len (e .WorkflowExecutionStartedEventAttributes .LastCompletionResult )
393
- eventSum += len (e .WorkflowExecutionStartedEventAttributes .Memo .GetFields ())
394
- }
395
- eh .eventsHandler .logger .Info (fmt .Sprintf ("WorkflowExecutionStartedEventAttributes size is %d" , eventSum ))
396
- case s .EventTypeWorkflowExecutionSignaled :
397
- if e .WorkflowExecutionSignaledEventAttributes != nil {
398
- eventSum += len (e .WorkflowExecutionSignaledEventAttributes .Input )
399
- }
400
- eh .eventsHandler .logger .Info (fmt .Sprintf ("WorkflowExecutionSignaledEventAttributes size is %d" , eventSum ))
401
- case s .EventTypeWorkflowExecutionFailed :
402
- if e .WorkflowExecutionFailedEventAttributes != nil {
403
- eventSum += len (e .WorkflowExecutionFailedEventAttributes .Details )
404
- }
405
- eh .eventsHandler .logger .Info (fmt .Sprintf ("WorkflowExecutionFailedEventAttributes size is %d" , eventSum ))
406
- case s .EventTypeDecisionTaskCompleted :
407
- if e .DecisionTaskCompletedEventAttributes != nil {
408
- eventSum += len (e .DecisionTaskCompletedEventAttributes .ExecutionContext )
409
- }
410
- eh .eventsHandler .logger .Info (fmt .Sprintf ("DecisionTaskCompletedEventAttributes size is %d" , eventSum ))
411
- case s .EventTypeDecisionTaskFailed :
412
- if e .DecisionTaskFailedEventAttributes != nil {
413
- eventSum += len (e .DecisionTaskFailedEventAttributes .Details )
414
- }
415
- eh .eventsHandler .logger .Info (fmt .Sprintf ("DecisionTaskFailedEventAttributes size is %d" , eventSum ))
416
- case s .EventTypeActivityTaskScheduled :
417
- if e .ActivityTaskScheduledEventAttributes != nil {
418
- eventSum += len (e .ActivityTaskScheduledEventAttributes .Input )
419
- eventSum += len (e .ActivityTaskScheduledEventAttributes .Header .GetFields ())
420
- }
421
- eh .eventsHandler .logger .Info (fmt .Sprintf ("ActivityTaskScheduledEventAttributes size is %d" , eventSum ))
422
- case s .EventTypeActivityTaskStarted :
423
- if e .ActivityTaskStartedEventAttributes != nil {
424
- eventSum += len (e .ActivityTaskStartedEventAttributes .LastFailureDetails )
425
- }
426
- eh .eventsHandler .logger .Info (fmt .Sprintf ("ActivityTaskStartedEventAttributes size is %d" , eventSum ))
427
- case s .EventTypeActivityTaskCompleted :
428
- if e .ActivityTaskCompletedEventAttributes != nil {
429
- eventSum += len (e .ActivityTaskCompletedEventAttributes .Result )
430
- }
431
- eh .eventsHandler .logger .Info (fmt .Sprintf ("ActivityTaskCompletedEventAttributes size is %d" , eventSum ))
432
- case s .EventTypeActivityTaskFailed :
433
- if e .ActivityTaskFailedEventAttributes != nil {
434
- eventSum += len (e .ActivityTaskFailedEventAttributes .Details )
435
- }
436
- eh .eventsHandler .logger .Info (fmt .Sprintf ("ActivityTaskFailedEventAttributes size is %d" , eventSum ))
437
- case s .EventTypeActivityTaskTimedOut :
438
- if e .ActivityTaskTimedOutEventAttributes != nil {
439
- eventSum += len (e .ActivityTaskTimedOutEventAttributes .Details )
440
- eventSum += len (e .ActivityTaskTimedOutEventAttributes .LastFailureDetails )
441
- }
442
- eh .eventsHandler .logger .Info (fmt .Sprintf ("ActivityTaskTimedOutEventAttributes size is %d" , eventSum ))
443
- case s .EventTypeActivityTaskCanceled :
444
- if e .ActivityTaskCanceledEventAttributes != nil {
445
- eventSum += len (e .ActivityTaskCanceledEventAttributes .Details )
446
- }
447
- eh .eventsHandler .logger .Info (fmt .Sprintf ("ActivityTaskCanceledEventAttributes size is %d" , eventSum ))
448
- case s .EventTypeMarkerRecorded :
449
- if e .MarkerRecordedEventAttributes != nil {
450
- eventSum += len (e .MarkerRecordedEventAttributes .Details )
451
- }
452
- eh .eventsHandler .logger .Info (fmt .Sprintf ("MarkerRecordedEventAttributes size is %d" , eventSum ))
453
- case s .EventTypeWorkflowExecutionTerminated :
454
- if e .WorkflowExecutionTerminatedEventAttributes != nil {
455
- eventSum += len (e .WorkflowExecutionTerminatedEventAttributes .Details )
456
- }
457
- eh .eventsHandler .logger .Info (fmt .Sprintf ("WorkflowExecutionTerminatedEventAttributes size is %d" , eventSum ))
458
- case s .EventTypeWorkflowExecutionCanceled :
459
- if e .WorkflowExecutionCanceledEventAttributes != nil {
460
- eventSum += len (e .WorkflowExecutionCanceledEventAttributes .Details )
461
- }
462
- eh .eventsHandler .logger .Info (fmt .Sprintf ("WorkflowExecutionCanceledEventAttributes size is %d" , eventSum ))
463
- case s .EventTypeWorkflowExecutionContinuedAsNew :
464
- if e .WorkflowExecutionContinuedAsNewEventAttributes != nil {
465
- eventSum += len (e .WorkflowExecutionContinuedAsNewEventAttributes .Input )
466
- eventSum += len (e .WorkflowExecutionContinuedAsNewEventAttributes .FailureDetails )
467
- eventSum += len (e .WorkflowExecutionContinuedAsNewEventAttributes .LastCompletionResult )
468
- eventSum += len (e .WorkflowExecutionContinuedAsNewEventAttributes .Memo .GetFields ())
469
- eventSum += len (e .WorkflowExecutionContinuedAsNewEventAttributes .Header .GetFields ())
470
- eventSum += len (e .WorkflowExecutionContinuedAsNewEventAttributes .SearchAttributes .GetIndexedFields ())
471
- }
472
- eh .eventsHandler .logger .Info (fmt .Sprintf ("WorkflowExecutionContinuedAsNewEventAttributes size is %d" , eventSum ))
473
- case s .EventTypeStartChildWorkflowExecutionInitiated :
474
- if e .StartChildWorkflowExecutionInitiatedEventAttributes != nil {
475
- eventSum += len (e .StartChildWorkflowExecutionInitiatedEventAttributes .Input )
476
- eventSum += len (e .StartChildWorkflowExecutionInitiatedEventAttributes .Control )
477
- eventSum += len (e .StartChildWorkflowExecutionInitiatedEventAttributes .Memo .GetFields ())
478
- eventSum += len (e .StartChildWorkflowExecutionInitiatedEventAttributes .Header .GetFields ())
479
- eventSum += len (e .StartChildWorkflowExecutionInitiatedEventAttributes .SearchAttributes .GetIndexedFields ())
480
- }
481
- eh .eventsHandler .logger .Info (fmt .Sprintf ("StartChildWorkflowExecutionInitiatedEventAttributes size is %d" , eventSum ))
482
- case s .EventTypeChildWorkflowExecutionCompleted :
483
- if e .ChildWorkflowExecutionCompletedEventAttributes != nil {
484
- eventSum += len (e .ChildWorkflowExecutionCompletedEventAttributes .Result )
485
- }
486
- eh .eventsHandler .logger .Info (fmt .Sprintf ("ChildWorkflowExecutionCompletedEventAttributes size is %d" , eventSum ))
487
- case s .EventTypeChildWorkflowExecutionFailed :
488
- if e .ChildWorkflowExecutionFailedEventAttributes != nil {
489
- eventSum += len (e .ChildWorkflowExecutionFailedEventAttributes .Details )
490
- }
491
- eh .eventsHandler .logger .Info (fmt .Sprintf ("ChildWorkflowExecutionFailedEventAttributes size is %d" , eventSum ))
492
- case s .EventTypeChildWorkflowExecutionCanceled :
493
- if e .ChildWorkflowExecutionCanceledEventAttributes != nil {
494
- eventSum += len (e .ChildWorkflowExecutionCanceledEventAttributes .Details )
495
- }
496
- eh .eventsHandler .logger .Info (fmt .Sprintf ("ChildWorkflowExecutionCanceledEventAttributes size is %d" , eventSum ))
497
- case s .EventTypeSignalExternalWorkflowExecutionInitiated :
498
- if e .SignalExternalWorkflowExecutionInitiatedEventAttributes != nil {
499
- eventSum += len (e .SignalExternalWorkflowExecutionInitiatedEventAttributes .Control )
500
- eventSum += len (e .SignalExternalWorkflowExecutionInitiatedEventAttributes .Input )
501
- }
502
- eh .eventsHandler .logger .Info (fmt .Sprintf ("SignalExternalWorkflowExecutionInitiatedEventAttributes size is %d" , eventSum ))
503
- default :
504
- // ignore other events
505
- }
506
- sum += eventSum
507
- }
508
- return sum
373
+ return nextEvents , markers , nil
509
374
}
510
375
511
376
func isPreloadMarkerEvent (event * s.HistoryEvent ) bool {
@@ -987,17 +852,15 @@ func (w *workflowExecutionContextImpl) ProcessWorkflowTask(workflowTask *workflo
987
852
// Process events
988
853
ProcessEvents:
989
854
for {
990
- reorderedEvents , markers , binaryChecksum , historySizeEstimation , err := reorderedHistory .NextDecisionEvents ()
855
+ reorderedEvents , markers , binaryChecksum , err := reorderedHistory .NextDecisionEvents ()
991
856
//w.workflowInfo.TotalHistoryBytes += int64(historySizeEstimation)
992
857
w .wth .logger .Info ("Differences between history size estimation and actual size" ,
993
- zap .Int ("HistoryEstimation" , historySizeEstimation ),
994
858
zap .Int64 ("HistorySizeEstimation" , w .workflowInfo .TotalHistoryBytes ),
995
859
zap .Int64 ("ActualHistorySize" , w .workflowInfo .HistoryBytesServer ),
996
860
zap .Int64 ("HistorySizeDiff" , w .workflowInfo .TotalHistoryBytes - w .workflowInfo .HistoryBytesServer ),
997
861
zap .Float64 ("DiffRatio" , float64 (w .workflowInfo .TotalHistoryBytes )/ float64 (w .workflowInfo .HistoryBytesServer )),
998
862
zap .String ("workflowType" , w .workflowInfo .WorkflowType .Name ))
999
- w .wth .metricsScope .GetTaggedScope ("workflowtype" , w .workflowInfo .WorkflowType .Name ).Gauge ("cadence-server-historysize" ).Update (float64 (w .workflowInfo .HistoryBytesServer ))
1000
- w .wth .metricsScope .GetTaggedScope ("workflowtype" , w .workflowInfo .WorkflowType .Name ).Gauge ("cadence-client-historysize" ).Update (float64 (historySizeEstimation ))
863
+ w .wth .metricsScope .GetTaggedScope ("workflowtype" , w .workflowInfo .WorkflowType .Name ).Gauge ("cadence-historysize-ratio" ).Update (float64 (w .workflowInfo .TotalHistoryBytes ) / float64 (w .workflowInfo .HistoryBytesServer ))
1001
864
if err != nil {
1002
865
return nil , err
1003
866
}
0 commit comments