@@ -25,21 +25,23 @@ class Puma
2525 ##
2626 # Start the puma collector
2727 #
28- def self . start
28+ def self . start ( client : nil , frequency : nil )
29+ return unless puma_enabled?
30+
2931 ::PrometheusExporter ::Instrumentation ::Puma . start (
30- client : ::Bigcommerce ::Prometheus . client ,
31- frequency : ::Bigcommerce ::Prometheus . puma_collection_frequency
32+ client : client || ::Bigcommerce ::Prometheus . client ,
33+ frequency : frequency || ::Bigcommerce ::Prometheus . puma_collection_frequency
3234 )
3335 if active_record_enabled?
3436 ::PrometheusExporter ::Instrumentation ::ActiveRecord . start (
35- client : ::Bigcommerce ::Prometheus . client ,
36- frequency : ::Bigcommerce ::Prometheus . puma_collection_frequency
37+ client : client || ::Bigcommerce ::Prometheus . client ,
38+ frequency : frequency || ::Bigcommerce ::Prometheus . puma_collection_frequency
3739 )
3840 end
3941 ::PrometheusExporter ::Instrumentation ::Process . start (
40- client : ::Bigcommerce ::Prometheus . client ,
42+ client : client || ::Bigcommerce ::Prometheus . client ,
4143 type : ::Bigcommerce ::Prometheus . puma_process_label ,
42- frequency : ::Bigcommerce ::Prometheus . puma_collection_frequency
44+ frequency : frequency || ::Bigcommerce ::Prometheus . puma_collection_frequency
4345 )
4446 end
4547
@@ -49,6 +51,13 @@ def self.start
4951 def self . active_record_enabled?
5052 defined? ( ActiveRecord ) && ::ActiveRecord ::Base . connection_pool . respond_to? ( :stat )
5153 end
54+
55+ ##
56+ # @return [Boolean]
57+ #
58+ def self . puma_enabled?
59+ defined? ( Puma ) && Puma . respond_to? ( :stats )
60+ end
5261 end
5362 end
5463 end
0 commit comments