Report activity schedule to start latency once per task without the activity type - #3101
RaphaelFakhri wants to merge 1 commit into
Conversation
maciejdudko
left a comment
There was a problem hiding this comment.
Hi @RaphaelFakhri, thank you for your contribution! However, this isn't the full fix for the issue.
Emitting the metric was correctly removed from ActivityPollTask and AsyncActivityPollTask. However, emitting it inside ActivityWorker.TaskHandlerImpl.handleActivity is still wrong. It should be moved into TaskHandlerImpl.handle method, just before the call to handleActivity. It also should use workerMetricsScope instead of the local metricsScope, because attaching worker and activity type to this metric is wrong (schedule-to-start latency is independent of activity type).
I left a separate comment about tests, please address it too.
Feel free to reach out to me on Temporal Community Slack if you need assistance with implementation.
There was a problem hiding this comment.
This new test suite is unnecessary. It's better to amend the existing io.temporal.workflow.MetricsTest. To ensure the metric is emitted only once, you can add a new overload of TestStatsReporter.assertTimer that takes Predicate<StatsAccumulator>, similar to how assertGauge works. To ensure the metric is not sent with wrong set of tags, you can use assertNoMetric.
fbacec8 to
d11802d
Compare
|
Thanks for the review. The timer is now recorded once in TaskHandlerImpl.handle on workerMetricsScope, and the assertions live in MetricsTest with the new assertTimer overload. |
What was changed
activity_schedule_to_start_latencytimer fromActivityPollTaskandAsyncActivityPollTask.ActivityWorker.TaskHandlerImpl.handleActivityintoTaskHandlerImpl.handle, just before the call tohandleActivity. It now usesworkerMetricsScope, so the metric carries no activity type or workflow type tags.TestStatsReporter.assertTimeroverload that takes aPredicate<StatsAccumulator>, modelled onassertGauge.TestStatsReporter.assertNoMetricnow also checks timers. It only checked counters before.MetricsTest.testWorkerMetricsasserts that the timer is reported exactly once on the activity worker tags and never on the tags that include the activity type.Why?
Each activity task recorded the schedule to start latency twice: once in the poll task and once in
handleActivitywith the activity type tags. Schedule to start latency does not depend on the activity type, so it is now recorded once per task on the worker scope.How was this tested?
With the change, all 9 tests pass. With the three source files reverted to
main,testWorkerMetricsfails because the timer is reported withactivity_type=Executeandworkflow_type=NoArgsWorkflow.Closes #2733