Skip to content

Commit aac2f9b

Browse files
committed
add logger and metric
1 parent e59bf0a commit aac2f9b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

internal/internal_task_handlers.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const (
5252

5353
noRetryBackoff = time.Duration(-1)
5454

55-
historySizeEstimationOffset = 1 * 1024
55+
historySizeEstimationOffset = 1 * 100
5656
)
5757

5858
type (
@@ -966,7 +966,14 @@ func (w *workflowExecutionContextImpl) ProcessWorkflowTask(workflowTask *workflo
966966
ProcessEvents:
967967
for {
968968
reorderedEvents, markers, binaryChecksum, historySizeEstimation, err := reorderedHistory.NextDecisionEvents()
969-
w.wth.logger.Info(fmt.Sprintf("The size estimation of history events for workflow task: %v,", historySizeEstimation))
969+
w.workflowInfo.TotalHistoryBytes += int64(historySizeEstimation)
970+
w.wth.logger.Info("Differences between history size estimation and actual size",
971+
zap.Int("HistoryEstimation", historySizeEstimation),
972+
zap.Int64("HistorySizeEstimation", w.workflowInfo.TotalHistoryBytes),
973+
zap.Int64("ActualHistorySize", w.workflowInfo.HistoryBytesServer),
974+
zap.Int64("HistorySizeDiff", w.workflowInfo.TotalHistoryBytes-w.workflowInfo.HistoryBytesServer))
975+
w.wth.metricsScope.GetTaggedScope("workflowtype", w.workflowInfo.WorkflowType.Name).Gauge("cadence-server-historysize").Update(float64(w.workflowInfo.HistoryBytesServer))
976+
w.wth.metricsScope.GetTaggedScope("workflowtype", w.workflowInfo.WorkflowType.Name).Gauge("cadence-client-historysize").Update(float64(historySizeEstimation))
970977
if err != nil {
971978
return nil, err
972979
}
@@ -1012,13 +1019,6 @@ ProcessEvents:
10121019
return nil, err
10131020
}
10141021

1015-
w.workflowInfo.TotalHistoryBytes += int64(historySizeEstimation)
1016-
w.wth.logger.Info("DIfferences between history size estimation and actual size",
1017-
zap.Int("HistoryEstimation", historySizeEstimation),
1018-
zap.Int64("HistorySizeEstimation", w.workflowInfo.TotalHistoryBytes),
1019-
zap.Int64("ActualHistorySize", w.workflowInfo.HistoryBytesServer),
1020-
zap.Int64("HistorySizeDiff", w.workflowInfo.TotalHistoryBytes-w.workflowInfo.HistoryBytesServer))
1021-
10221022
err = eventHandler.ProcessEvent(event, isInReplay, isLast)
10231023
if err != nil {
10241024
return nil, err

0 commit comments

Comments
 (0)