Fix upload/download stats to use wall-clock duration#2388
Open
amit-writes-code wants to merge 1 commit into
Open
Fix upload/download stats to use wall-clock duration#2388amit-writes-code wants to merge 1 commit into
amit-writes-code wants to merge 1 commit into
Conversation
Use edge detection (Start/Stop) to bracket visitProtoPayloads rather than summing individual PayloadBatchCompleted durations Fixes temporalio#2378
Author
|
@jmaeagle99 would love to know if there is any scope of optimzations here, in terms of accuracy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use edge detection (Start/Stop) to bracket visitProtoPayloads rather than
summing individual PayloadBatchCompleted durations
Fixes #2378
What was changed
internal/internal_task_pollers.gototalDuration time.Durationfield onworkflowTaskStorageMetricswith
startTimeandendTime time.Timefields.Start()— records wall-clock start immediately beforevisitProtoPayloadsis called (rising edge).Stop()— records wall-clock end immediately aftervisitProtoPayloadsreturns (falling edge), before any subsequentworkflow execution or network calls.
WallClockDuration()— returnsendTime.Sub(startTime), a fixedinterval between two captured timestamps. Replaces
totalDurationatboth log sites (
tagPayloadDownloadDuration,tagPayloadUploadDuration).PayloadBatchCompletedno longer accumulatesduration— it only trackspayloadCount,totalSize, anddriverNames.internal/internal_task_pollers_test.goTestWorkflowTaskStorageMetrics_WallClockDuration— verifies theStart/Stop/WallClockDuration lifecycle: returns 0 before
Start(),returns 0 before
Stop(), returns a positive duration afterStop(),does not shrink on a second
Stop()call.TestWorkflowTaskStorageMetrics_PayloadBatchCompleted— simulates twoconcurrent callbacks and asserts that
payloadCountandtotalSizeaccumulate correctly, driver names are collected from both callbacks,
and wall-clock duration is less than the sum of individual durations
(proving edge detection rather than summation).
Why?
PayloadBatchCompletedwas called once perVisitinvocation with adurationargument representing the wall-clock time for that Visit.When
payloadVisitorConcurrency > 1, multiple Visit calls runconcurrently. Summing their individual durations overcounts proportionally
to the number of concurrent visits:
Checklist
TestWorkflowTaskStorageMetrics_WallClockDuration— unit test forthe Start/Stop/WallClockDuration lifecycle.
TestWorkflowTaskStorageMetrics_PayloadBatchCompleted— concurrentcallbacks assert wall-clock < sum of individual durations.
go test ./internal/ -run "TestWorkflowTaskStorageMetrics" -vpublic API or user-visible behavior change.