Emit 'busy_threads' as 'workers.busy_threads' - #47
Open
pifantastic wants to merge 1 commit into
Open
Conversation
Puma reports the number of threads currently serving requests as 'busy_threads'. Expose it as a 'workers.busy_threads' metric. Puma only added this stat in 6.6, so it is included in DEFAULT_PUMA_TELEMETRY on 6.6 and newer and left out on older versions. Selecting it explicitly on an older puma raises a Telemetry::Error naming the required version, rather than silently publishing a metric that is always 0. The puma dependency itself is unchanged. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Puma reports the number of threads currently serving requests as
busy_threads. This exposes it as aworkers.busy_threadsmetric, alongside the existingworkers.spawned_threadsandworkers.max_threads.It's a useful signal on its own:
spawned_threadstells you how many threads exist, but not how many are actually doing work. Together withqueue.capacityit makes saturation directly visible rather than something you infer.Puma version handling
Puma only added the
busy_threadsstat in 6.6, and this gem's dependency ispuma < 9with no lower bound. Rather than raising the floor, the metric is version-aware:DEFAULT_PUMA_TELEMETRY, so it's published out of the box.Puma::Plugin::Telemetry::Errorthat names the required version, instead of silently publishing a metric that is always0.The
pumadependency in the gemspec is unchanged.Notes
WorkerData(single mode) andClusteredData(clustered mode, summed across workers) are covered.workers.busy_threadsis present rather than pinning its value, since it depends on what the server happens to be doing when telemetry is published.Metrics/ModuleLengthis now excluded forspec/**/*, matching the existing exclusions forMetrics/BlockLengthandMetrics/ClassLength.bundle exec rakepasses: 65 examples, 0 failures (1 pending — the socket telemetry spec, which is skipped on macOS), RuboCop clean.🤖 Generated with Claude Code