Skip to content

Commit

Permalink
Emit metric for activity eager execution (#3110)
Browse files Browse the repository at this point in the history
  • Loading branch information
yycptt committed Jul 18, 2022
1 parent d0ebe68 commit e55f328
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions common/metrics/defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2121,6 +2121,7 @@ const (
CommandTypeContinueAsNewCounter
CommandTypeSignalExternalWorkflowCounter
CommandTypeUpsertWorkflowSearchAttributesCounter
ActivityEagerExecutionCounter
EmptyCompletionCommandsCounter
MultipleCompletionCommandsCounter
FailedWorkflowTasksCounter
Expand Down Expand Up @@ -2604,6 +2605,7 @@ var MetricDefs = map[ServiceIdx]map[int]metricDefinition{
CommandTypeSignalExternalWorkflowCounter: NewCounterDef("signal_external_workflow_command"),
CommandTypeUpsertWorkflowSearchAttributesCounter: NewCounterDef("upsert_workflow_search_attributes_command"),
CommandTypeChildWorkflowCounter: NewCounterDef("child_workflow_command"),
ActivityEagerExecutionCounter: NewCounterDef("activity_eager_execution"),
EmptyCompletionCommandsCounter: NewCounterDef("empty_completion_commands"),
MultipleCompletionCommandsCounter: NewCounterDef("multiple_completion_commands"),
FailedWorkflowTasksCounter: NewCounterDef("failed_workflow_tasks"),
Expand Down
3 changes: 2 additions & 1 deletion service/frontend/dcRedirectionHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1656,14 +1656,15 @@ func (handler *DCRedirectionHandlerImpl) UpdateWorkflow(
switch {
case targetDC == handler.currentClusterName:
resp, err = handler.frontendHandler.UpdateWorkflow(ctx, request)
return err
default:
remoteClient, err := handler.clientBean.GetRemoteFrontendClient(targetDC)
if err != nil {
return err
}
resp, err = remoteClient.UpdateWorkflow(ctx, request)
return err
}
return err
})

return resp, err
Expand Down
6 changes: 6 additions & 0 deletions service/history/workflowTaskHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,12 @@ func (handler *workflowTaskHandlerImpl) handlePostCommandEagerExecuteActivity(
WorkflowNamespace: handler.mutableState.GetNamespaceEntry().Name().String(),
}

handler.metricsClient.Scope(
metrics.HistoryRespondWorkflowTaskCompletedScope,
metrics.NamespaceTag(string(handler.mutableState.GetNamespaceEntry().Name())),
metrics.TaskQueueTag(ai.TaskQueue),
).IncCounter(metrics.ActivityEagerExecutionCounter)

return func(resp *historyservice.RespondWorkflowTaskCompletedResponse) error {
resp.ActivityTasks = append(resp.ActivityTasks, activityTask)
return nil
Expand Down

0 comments on commit e55f328

Please sign in to comment.