diff --git a/lib/puma/plugin/statsd.rb b/lib/puma/plugin/statsd.rb index 565f16f..2b65940 100644 --- a/lib/puma/plugin/statsd.rb +++ b/lib/puma/plugin/statsd.rb @@ -16,10 +16,6 @@ def initialize @port = ENV.fetch("STATSD_PORT", 8125) end - def enabled? - !!host - end - def send(metric_name:, value:, type:, tags: nil) data = "#{metric_name}:#{value}|#{STATSD_TYPES.fetch(type)}" data = "#{data}|##{tags}" unless tags.nil? @@ -88,19 +84,15 @@ def start(launcher) @launcher = launcher @statsd = ::StatsdConnector.new - if @statsd.enabled? - @launcher.events.debug "statsd: enabled (host: #{@statsd.host})" - - # Fetch global metric prefix from env variable - @metric_prefix = ENV.fetch("STATSD_METRIC_PREFIX", nil) - if @metric_prefix && !@metric_prefix.end_with?(::StatsdConnector::METRIC_DELIMETER) - @metric_prefix += ::StatsdConnector::METRIC_DELIMETER - end + @launcher.events.debug "statsd: enabled (host: #{@statsd.host})" - register_hooks - else - @launcher.events.debug "statsd: not enabled (no #{StatsdConnector::ENV_NAME} env var found)" + # Fetch global metric prefix from env variable + @metric_prefix = ENV.fetch("STATSD_METRIC_PREFIX", nil) + if @metric_prefix && !@metric_prefix.end_with?(::StatsdConnector::METRIC_DELIMETER) + @metric_prefix += ::StatsdConnector::METRIC_DELIMETER end + + register_hooks end private