Skip to content

Commit 725b428

Browse files
authoredMay 21, 2024··
Only record activity_succeed_endtoend_latency on success (#1481)
1 parent aa17647 commit 725b428

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed
 

‎internal/internal_task_pollers.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -1023,9 +1023,11 @@ func (atp *activityTaskPoller) ProcessTask(task interface{}) error {
10231023
return reportErr
10241024
}
10251025

1026-
activityMetricsHandler.
1027-
Timer(metrics.ActivitySucceedEndToEndLatency).
1028-
Record(time.Since(activityTask.task.GetScheduledTime().AsTime()))
1026+
if _, ok := request.(*workflowservice.RespondActivityTaskCompletedRequest); ok {
1027+
activityMetricsHandler.
1028+
Timer(metrics.ActivitySucceedEndToEndLatency).
1029+
Record(time.Since(activityTask.task.GetScheduledTime().AsTime()))
1030+
}
10291031
return nil
10301032
}
10311033

‎test/integration_test.go

+33
Original file line numberDiff line numberDiff line change
@@ -1825,6 +1825,39 @@ func (ts *IntegrationTestSuite) TestEndToEndLatencyMetrics() {
18251825
ts.Equal(prevNonLocalValue, nonLocal.Value())
18261826
}
18271827

1828+
func (ts *IntegrationTestSuite) TestEndToEndLatencyOnFailureMetrics() {
1829+
fetchMetrics := func() (localMetric, nonLocalMetric *metrics.CapturedTimer) {
1830+
for _, timer := range ts.metricsHandler.Timers() {
1831+
timer := timer
1832+
if timer.Name == "temporal_activity_succeed_endtoend_latency" {
1833+
nonLocalMetric = timer
1834+
} else if timer.Name == "temporal_local_activity_succeed_endtoend_latency" {
1835+
localMetric = timer
1836+
}
1837+
}
1838+
return
1839+
}
1840+
1841+
// Confirm no metrics to start
1842+
local, nonLocal := fetchMetrics()
1843+
ts.Nil(local)
1844+
ts.Nil(nonLocal)
1845+
1846+
// Run regular activity and confirm non-local metric is not emitted
1847+
err := ts.executeWorkflow("test-end-to-end-metrics-on-failure-1", ts.workflows.ActivityRetryOnError, nil)
1848+
ts.NoError(err)
1849+
local, nonLocal = fetchMetrics()
1850+
ts.Nil(local)
1851+
ts.Nil(nonLocal)
1852+
1853+
// Run local activity and confirm local metric is not emitted
1854+
err = ts.executeWorkflow("test-end-to-end-metrics-on-failure-2", ts.workflows.ActivityRetryOnError, nil)
1855+
ts.NoError(err)
1856+
local, nonLocal = fetchMetrics()
1857+
ts.Nil(local)
1858+
ts.Nil(nonLocal)
1859+
}
1860+
18281861
func (ts *IntegrationTestSuite) TestGracefulActivityCompletion() {
18291862
// FYI, setup of this test allows the worker to wait to stop for 10 seconds
18301863
ctx, cancel := context.WithCancel(context.Background())

0 commit comments

Comments
 (0)
Please sign in to comment.