puma_workers: ::Gitlab::Metrics.gauge(:puma_workers,'Total number of workers'),
puma_running_workers: ::Gitlab::Metrics.gauge(:puma_running_workers,'Number of active workers'),
puma_stale_workers: ::Gitlab::Metrics.gauge(:puma_stale_workers,'Number of stale workers'),
puma_phase: ::Gitlab::Metrics.gauge(:puma_phase,'Phase number (increased during phased restarts)'),
puma_running: ::Gitlab::Metrics.gauge(:puma_running,'Number of running threads'),
puma_queued_connections: ::Gitlab::Metrics.gauge(:puma_queued_connections,'Number of connections in that worker\'s "todo" set waiting for a worker thread'),
puma_active_connections: ::Gitlab::Metrics.gauge(:puma_active_connections,'Number of threads processing a request'),
puma_pool_capacity: ::Gitlab::Metrics.gauge(:puma_pool_capacity,'Number of requests the worker is capable of taking right now'),
puma_max_threads: ::Gitlab::Metrics.gauge(:puma_max_threads,'Maximum number of worker threads'),
puma_idle_threads: ::Gitlab::Metrics.gauge(:puma_idle_threads,'Number of spawned threads which are not processing a request')
}
end
defsample
json_stats=puma_stats
returnunlessjson_stats
stats=JSON.parse(json_stats)
ifcluster?(stats)
sample_cluster(stats)
else
sample_single_worker(stats)
end
end
private
defpuma_stats
Puma.stats
rescueNoMethodError
Rails.logger.info"PumaSampler: stats are not available yet, waiting for Puma to boot"