Skip to content

temporal: Emit accurate Ruby worker slot metrics - #4

Draft
kstewartfigma wants to merge 1 commit into
masterfrom
kstewart/ruby-worker-slot-metrics
Draft

temporal: Emit accurate Ruby worker slot metrics#4
kstewartfigma wants to merge 1 commit into
masterfrom
kstewart/ruby-worker-slot-metrics

Conversation

@kstewartfigma

Copy link
Copy Markdown

Why

Ruby Temporal worker processes currently emit thread_pool.available_threads into the same DogStatsD metric context. With multiple worker processes sharing a pod or host, the last gauge write wins, so the metric does not represent fleet slot saturation.

What changed

  • preserve the existing thread_pool.available_threads metric for compatibility
  • add Temporal-standard worker_task_slots_available and worker_task_slots_used gauges
  • tag the new gauges with namespace, task_queue, worker_type, and a unique worker_id so concurrent processes cannot overwrite one another
  • report an initial snapshot and refresh it every 10 seconds, including while idle
  • stop the reporter before enqueueing shutdown sentinels so shutdown does not appear as real slot use

Test plan

  • bundle exec rspec spec/unit/lib/temporal/thread_pool_spec.rb spec/unit/lib/temporal/activity/poller_spec.rb spec/unit/lib/temporal/workflow/poller_spec.rb
  • 28 examples, 0 failures
  • ruby -c on all changed Ruby files

The full suite has 10 unrelated failures under local Ruby 3.4 that reproduce on an untouched master worktree. This repository's GitHub workflow runs Ruby 3.0.3.

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