[codex] Add workflow up-down-counter lifecycle cleanup#2096
Draft
gibbonjj wants to merge 7 commits into
Draft
Conversation
Introduces the worker-side WorkflowMetricsTracker class that owns the injected sink for UpDownCounter metric values from the workflow sandbox. This first task implements only the first-emission delta path (oldNet=0, delta=newNet) along with a unit test that verifies a single emission hits the underlying MetricMeter with the full value. Also extends the WorkflowMetricMeter sink interface in @temporalio/workflow with addMetricUpDownCounterValue, and adds a no-op implementation in the legacy initMetricSink so the existing worker options path still typechecks; later tasks will replace initMetricSink with the tracker entirely. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… subscribe cleanup to evictionsEmitter
ef876c3 to
dcf6a7c
Compare
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.
What changed
Why
Workflow up-down counters are stateful in worker memory. Replays can happen on different workers, and externally terminal histories such as timeout or termination can leave cached workflow contributions live unless core sends the usual eviction signal. The companion core change makes those terminal histories produce
RemoveFromCache(WORKFLOW_EXECUTION_ENDING), which lets the TypeScript worker clean up the tracked contribution.Depends on temporalio/sdk-rust#1305.
Validation
cargo +stable test -p temporalio-sdk-core external_terminal_events_request_cache_eviction --libpnpm --filter @temporalio/test build:tspnpm -C packages/test exec ava lib/test-up-down-counter-replay.jsgit diff --checkgit -C packages/core-bridge/sdk-core diff --checkNotes
This fixes live worker lifecycle cleanup for replay, cache eviction, timeout, and termination. It does not attempt to make push-based OTel exact across a hard worker/pod crash, since a dead process cannot emit the compensating negative delta.