@@ -916,9 +916,10 @@ func newActivityTaskPoller(taskHandler ActivityTaskHandler, service workflowserv
916
916
}
917
917
918
918
// Poll for a single activity task from the service
919
- func (atp * activityTaskPoller ) poll (ctx context.Context ) (* s.PollForActivityTaskResponse , error ) {
919
+ func (atp * activityTaskPoller ) poll (ctx context.Context ) (* s.PollForActivityTaskResponse , time. Time , error ) {
920
920
921
921
atp .metricsScope .Counter (metrics .ActivityPollCounter ).Inc (1 )
922
+ startTime := time .Now ()
922
923
923
924
traceLog (func () {
924
925
atp .logger .Debug ("activityTaskPoller::Poll" )
@@ -937,28 +938,27 @@ func (atp *activityTaskPoller) poll(ctx context.Context) (*s.PollForActivityTask
937
938
} else {
938
939
atp .metricsScope .Counter (metrics .ActivityPollFailedCounter ).Inc (1 )
939
940
}
940
- return nil , err
941
+ return nil , startTime , err
941
942
}
942
943
if response == nil || len (response .TaskToken ) == 0 {
943
944
atp .metricsScope .Counter (metrics .ActivityPollNoTaskCounter ).Inc (1 )
944
- return nil , nil
945
+ return nil , startTime , nil
945
946
}
946
947
947
- return response , err
948
+ return response , startTime , err
948
949
}
949
950
950
- type pollFunc func (ctx context.Context ) (* s.PollForActivityTaskResponse , error )
951
+ type pollFunc func (ctx context.Context ) (* s.PollForActivityTaskResponse , time. Time , error )
951
952
952
953
func (atp * activityTaskPoller ) pollWithMetricsFunc (
953
954
pollFunc pollFunc ) func (ctx context.Context ) (interface {}, error ) {
954
955
return func (ctx context.Context ) (interface {}, error ) { return atp .pollWithMetrics (ctx , pollFunc ) }
955
956
}
956
957
957
958
func (atp * activityTaskPoller ) pollWithMetrics (ctx context.Context ,
958
- pollFunc func (ctx context.Context ) (* s.PollForActivityTaskResponse , error )) (interface {}, error ) {
959
- startTime := time .Now ()
959
+ pollFunc func (ctx context.Context ) (* s.PollForActivityTaskResponse , time.Time , error )) (interface {}, error ) {
960
960
961
- response , err := pollFunc (ctx )
961
+ response , startTime , err := pollFunc (ctx )
962
962
if err != nil {
963
963
return nil , err
964
964
}
@@ -1057,12 +1057,14 @@ func (atp *locallyDispatchedActivityTaskPoller) PollTask() (interface{}, error)
1057
1057
return activityTask , nil
1058
1058
}
1059
1059
1060
- func (atp * locallyDispatchedActivityTaskPoller ) pollLocallyDispatchedActivity (ctx context.Context ) (* s.PollForActivityTaskResponse , error ) {
1060
+ func (atp * locallyDispatchedActivityTaskPoller ) pollLocallyDispatchedActivity (ctx context.Context ) (* s.PollForActivityTaskResponse , time. Time , error ) {
1061
1061
task := atp .ldaTunnel .getTask ()
1062
1062
atp .metricsScope .Counter (metrics .LocallyDispatchedActivityPollCounter ).Inc (1 )
1063
+ // consider to remove the poll latency metric for local dispatch as unnecessary
1064
+ startTime := time .Now ()
1063
1065
if task == nil {
1064
1066
atp .metricsScope .Counter (metrics .LocallyDispatchedActivityPollNoTaskCounter ).Inc (1 )
1065
- return nil , nil
1067
+ return nil , startTime , nil
1066
1068
}
1067
1069
// to be backwards compatible, update total poll counter if optimization succeeded only
1068
1070
atp .metricsScope .Counter (metrics .ActivityPollCounter ).Inc (1 )
@@ -1083,7 +1085,7 @@ func (atp *locallyDispatchedActivityTaskPoller) pollLocallyDispatchedActivity(ct
1083
1085
response .WorkflowType = task .WorkflowType
1084
1086
response .WorkflowDomain = task .WorkflowDomain
1085
1087
response .Attempt = common .Int32Ptr (0 )
1086
- return response , nil
1088
+ return response , startTime , nil
1087
1089
}
1088
1090
1089
1091
func reportActivityComplete (ctx context.Context , service workflowserviceclient.Interface , request interface {}, metricsScope tally.Scope ) error {
0 commit comments