Skip to content

Commit 9e37aeb

Browse files
committed
Add more fields to calculation, remove logger, keep a metric for the ratio for monitoring
1 parent 2aae765 commit 9e37aeb

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

internal/internal_event_handlers.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import (
4444

4545
const (
4646
queryResultSizeLimit = 2000000 // 2MB
47-
historySizeEstimationBuffer = 384 // 384B
47+
historySizeEstimationBuffer = 400 // 400B for common fields in history event
4848
)
4949

5050
// Make sure that interfaces are implemented
@@ -1394,6 +1394,12 @@ func (weh *workflowExecutionEventHandlerImpl) estimateHistorySize(event *m.Histo
13941394
sum += len(event.WorkflowExecutionStartedEventAttributes.ContinuedFailureDetails)
13951395
sum += len(event.WorkflowExecutionStartedEventAttributes.LastCompletionResult)
13961396
sum += len(event.WorkflowExecutionStartedEventAttributes.Memo.GetFields())
1397+
sum += len(event.WorkflowExecutionStartedEventAttributes.Header.GetFields())
1398+
sum += len(event.WorkflowExecutionStartedEventAttributes.SearchAttributes.GetIndexedFields())
1399+
}
1400+
case m.EventTypeWorkflowExecutionCompleted:
1401+
if event.WorkflowExecutionCompletedEventAttributes != nil {
1402+
sum += len(event.WorkflowExecutionCompletedEventAttributes.Result)
13971403
}
13981404
case m.EventTypeWorkflowExecutionSignaled:
13991405
if event.WorkflowExecutionSignaledEventAttributes != nil {

internal/internal_task_handlers.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -853,13 +853,6 @@ func (w *workflowExecutionContextImpl) ProcessWorkflowTask(workflowTask *workflo
853853
ProcessEvents:
854854
for {
855855
reorderedEvents, markers, binaryChecksum, err := reorderedHistory.NextDecisionEvents()
856-
//w.workflowInfo.TotalHistoryBytes += int64(historySizeEstimation)
857-
w.wth.logger.Info("Differences between history size estimation and actual size",
858-
zap.Int64("HistorySizeEstimation", w.workflowInfo.TotalHistoryBytes),
859-
zap.Int64("ActualHistorySize", w.workflowInfo.HistoryBytesServer),
860-
zap.Int64("HistorySizeDiff", w.workflowInfo.TotalHistoryBytes-w.workflowInfo.HistoryBytesServer),
861-
zap.Float64("DiffRatio", float64(w.workflowInfo.TotalHistoryBytes)/float64(w.workflowInfo.HistoryBytesServer)),
862-
zap.String("workflowType", w.workflowInfo.WorkflowType.Name))
863856
w.wth.metricsScope.GetTaggedScope("workflowtype", w.workflowInfo.WorkflowType.Name).Gauge("cadence-historysize-ratio").Update(float64(w.workflowInfo.TotalHistoryBytes) / float64(w.workflowInfo.HistoryBytesServer))
864857
if err != nil {
865858
return nil, err

0 commit comments

Comments
 (0)