class Bigcommerce::Prometheus::Integrations::Puma

Plugin for puma

Public Class Methods

active_record_enabled?() click to toggle source

@return [Boolean]

# File lib/bigcommerce/prometheus/integrations/puma.rb, line 53
def self.active_record_enabled?
  defined?(ActiveRecord) && ::ActiveRecord::Base.connection_pool.respond_to?(:stat)
end
puma_enabled?() click to toggle source

@return [Boolean]

# File lib/bigcommerce/prometheus/integrations/puma.rb, line 60
def self.puma_enabled?
  defined?(::Puma) && ::Puma.respond_to?(:stats)
end
start(client: nil, frequency: nil) click to toggle source

Start the puma collector

# File lib/bigcommerce/prometheus/integrations/puma.rb, line 28
def self.start(client: nil, frequency: nil)
  return unless puma_enabled?

  if puma_enabled?
    ::PrometheusExporter::Instrumentation::Puma.start(
      client: client || ::Bigcommerce::Prometheus.client,
      frequency: frequency || ::Bigcommerce::Prometheus.puma_collection_frequency
    )
  end
  if active_record_enabled?
    ::PrometheusExporter::Instrumentation::ActiveRecord.start(
      client: client || ::Bigcommerce::Prometheus.client,
      frequency: frequency || ::Bigcommerce::Prometheus.puma_collection_frequency
    )
  end
  ::PrometheusExporter::Instrumentation::Process.start(
    client: client || ::Bigcommerce::Prometheus.client,
    type: ::Bigcommerce::Prometheus.puma_process_label,
    frequency: frequency || ::Bigcommerce::Prometheus.puma_collection_frequency
  )
end