@@ -135,19 +135,19 @@ func GetPerTaskQueueFamilyScope(
135135 )
136136}
137137
138- type ActivityExecutionState int
138+ type ActivityExecutionStatus int
139139
140140const (
141- ActivityStateUnknown ActivityExecutionState = iota
142- ActivityStateSucceeded
143- ActivityStateFailed
144- ActivityStateCanceled
145- ActivityStateTimeout
141+ ActivityStatusUnknown ActivityExecutionStatus = iota
142+ ActivityStatusSucceeded
143+ ActivityStatusFailed
144+ ActivityStatusCanceled
145+ ActivityStatusTimeout
146146)
147147
148148type ActivityCompletionMetrics struct {
149- // State determines whether the activity succeeded, and whether it is/will be retried
150- State ActivityExecutionState
149+ // Status determines whether the activity succeeded, and whether it is/will be retried
150+ Status ActivityExecutionStatus
151151 // AttemptStartedTime is the start time of the current attempt
152152 AttemptStartedTime time.Time
153153 // FirstScheduledTime is the scheduled time of the first attempt
@@ -162,7 +162,7 @@ func RecordActivityCompletionMetrics(
162162 shard historyi.ShardContext ,
163163 namespaceName namespace.Name ,
164164 taskQueue string ,
165- metricsState ActivityCompletionMetrics ,
165+ completion ActivityCompletionMetrics ,
166166 tags ... metrics.Tag ,
167167) {
168168 metricsHandler := GetPerTaskQueueFamilyScope (
@@ -173,33 +173,33 @@ func RecordActivityCompletionMetrics(
173173 tags ... ,
174174 )
175175
176- if ! metricsState .AttemptStartedTime .IsZero () {
177- latency := time .Since (metricsState .AttemptStartedTime )
176+ if ! completion .AttemptStartedTime .IsZero () && completion . Status != ActivityStatusTimeout {
177+ latency := time .Since (completion .AttemptStartedTime )
178178 // ActivityE2ELatency is deprecated due to its inaccurate naming. It captures the attempt duration instead of an end-to-end duration as its name suggests. For now record both metrics
179179 metrics .ActivityE2ELatency .With (metricsHandler ).Record (latency )
180180 metrics .ActivityStartToCloseLatency .With (metricsHandler ).Record (latency )
181181 }
182182
183183 // Record true end-to-end duration only for terminal states (includes retries and backoffs)
184- if metricsState .Closed && ! metricsState .FirstScheduledTime .IsZero () {
185- scheduleToCloseLatency := time .Since (metricsState .FirstScheduledTime )
184+ if completion .Closed && ! completion .FirstScheduledTime .IsZero () {
185+ scheduleToCloseLatency := time .Since (completion .FirstScheduledTime )
186186 metrics .ActivityScheduleToCloseLatency .With (metricsHandler ).Record (scheduleToCloseLatency )
187187 }
188188
189- switch metricsState . State {
190- case ActivityStateFailed :
189+ switch completion . Status {
190+ case ActivityStatusFailed :
191191 metrics .ActivityTaskFail .With (metricsHandler ).Record (1 )
192- if metricsState .Closed {
192+ if completion .Closed {
193193 metrics .ActivityFail .With (metricsHandler ).Record (1 )
194194 }
195- case ActivityStateCanceled :
195+ case ActivityStatusCanceled :
196196 metrics .ActivityCancel .With (metricsHandler ).Record (1 )
197- case ActivityStateSucceeded :
197+ case ActivityStatusSucceeded :
198198 metrics .ActivitySuccess .With (metricsHandler ).Record (1 )
199- case ActivityStateTimeout :
200- metrics .ActivityTaskTimeout .With (metricsHandler ).Record (1 , metrics .StringTag ("timeout_type" , metricsState .TimerType .String ()))
201- if metricsState .Closed {
202- metrics .ActivityTimeout .With (metricsHandler ).Record (1 , metrics .StringTag ("timeout_type" , metricsState .TimerType .String ()))
199+ case ActivityStatusTimeout :
200+ metrics .ActivityTaskTimeout .With (metricsHandler ).Record (1 , metrics .StringTag ("timeout_type" , completion .TimerType .String ()))
201+ if completion .Closed {
202+ metrics .ActivityTimeout .With (metricsHandler ).Record (1 , metrics .StringTag ("timeout_type" , completion .TimerType .String ()))
203203 }
204204 default :
205205 // Do nothing
0 commit comments