Skip to content

[codex] Add workflow up-down-counter lifecycle cleanup#2096

Draft
gibbonjj wants to merge 7 commits into
temporalio:mainfrom
gibbonjj:updown_counter_workflow_activity_nexus
Draft

[codex] Add workflow up-down-counter lifecycle cleanup#2096
gibbonjj wants to merge 7 commits into
temporalio:mainfrom
gibbonjj:updown_counter_workflow_activity_nexus

Conversation

@gibbonjj
Copy link
Copy Markdown
Contributor

What changed

  • Adds workflow up-down-counter metric coverage to the custom metrics workflow test.
  • Makes workflow up-down-counter tracking descriptor-aware and collision-safe for tag keys.
  • Keeps per-workflow absolute-net replay behavior, while the worker applies only deltas and removes contributions on cache eviction.
  • Updates the sdk-core submodule to include the external terminal-event eviction fix.

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 --lib
  • pnpm --filter @temporalio/test build:ts
  • pnpm -C packages/test exec ava lib/test-up-down-counter-replay.js
  • git diff --check
  • git -C packages/core-bridge/sdk-core diff --check

Notes

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.

gibbonjj and others added 7 commits May 30, 2026 09:08
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>
@gibbonjj gibbonjj force-pushed the updown_counter_workflow_activity_nexus branch from ef876c3 to dcf6a7c Compare May 30, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant