class Gruf::Prometheus::TypeCollector

Type Collector for prometheus and grpc instrumentation

Public Instance Methods

type() click to toggle source
# File lib/gruf/prometheus/type_collector.rb, line 24
def type
  'grpc'
end

Private Instance Methods

build_metrics() click to toggle source

Initialize the collector

# File lib/gruf/prometheus/type_collector.rb, line 33
def build_metrics
  {
    pool_jobs_waiting_total: PrometheusExporter::Metric::Gauge.new('grpc_pool_jobs_waiting_total', 'Number jobs in the gRPC thread pool that are actively waiting'),
    pool_ready_workers_total: PrometheusExporter::Metric::Gauge.new('grpc_pool_ready_workers_total', 'The amount of non-busy workers in the thread pool'),
    pool_workers_total: PrometheusExporter::Metric::Gauge.new('grpc_pool_workers_total', 'Number of workers in the gRPC thread pool'),
    pool_initial_size: PrometheusExporter::Metric::Gauge.new('grpc_pool_initial_size', 'Initial size of the gRPC thread pool'),
    poll_period: PrometheusExporter::Metric::Gauge.new('grpc_poll_period', 'Polling period for the gRPC thread pool'),
    thread_pool_exhausted: PrometheusExporter::Metric::Counter.new('grpc_thread_pool_exhausted', 'Times the gRPC thread pool has been exhausted')
  }
end
collect_metrics(data: {}, labels: {}) click to toggle source

Collect the object into the buffer

# File lib/gruf/prometheus/type_collector.rb, line 47
def collect_metrics(data: {}, labels: {})
  metric(:pool_jobs_waiting_total)&.observe(data['pool_jobs_waiting_total'].to_i, labels)
  metric(:pool_ready_workers_total)&.observe(data['pool_ready_workers_total'].to_i, labels)
  metric(:pool_workers_total)&.observe(data['pool_workers_total'].to_i, labels)
  metric(:pool_initial_size)&.observe(data['pool_initial_size'].to_i, labels)
  metric(:poll_period)&.observe(data['poll_period'].to_i, labels)
  metric(:thread_pool_exhausted)&.observe(data['thread_pool_exhausted'].to_i, labels)
end