Sha256: 6f5fae48f9b2664b6ac03ae1bfd4bc2ed3be676cc0379ff4b7079042d37dc9d7
Contents?: true
Size: 1.32 KB
Versions: 2
Compression:
Stored size: 1.32 KB
Contents
# frozen_string_literal: true module PrometheusExporter::Server class PumaCollector < TypeCollector PUMA_GAUGES = { workers_total: "Number of puma workers.", booted_workers_total: "Number of puma workers booted.", old_workers_total: "Number of old puma workers.", running_threads_total: "Number of puma threads currently running.", request_backlog_total: "Number of requests waiting to be processed by a puma thread.", thread_pool_capacity_total: "Number of puma threads available at current scale.", max_threads_total: "Number of puma threads at available at max scale.", } def initialize @puma_metrics = [] end def type "puma" end def metrics return [] if @puma_metrics.length == 0 metrics = {} @puma_metrics.map do |m| labels = {} if m["phase"] labels.merge!(phase: m["phase"]) end if m["custom_labels"] labels.merge!(m["custom_labels"]) end PUMA_GAUGES.map do |k, help| k = k.to_s if v = m[k] g = metrics[k] ||= PrometheusExporter::Metric::Gauge.new("puma_#{k}", help) g.observe(v, labels) end end end metrics.values end def collect(obj) @puma_metrics << obj end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
prometheus_exporter-0.4.12 | lib/prometheus_exporter/server/puma_collector.rb |
prometheus_exporter-0.4.11 | lib/prometheus_exporter/server/puma_collector.rb |