Sha256: e58e0a314769c166f3dfd38bd64fe6abfce831daa8d2c17cb5684709c7a54868

Contents?: true

Size: 1.42 KB

Versions: 26

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

module Appsignal
  class Hooks
    # @api private
    class PumaHook < Appsignal::Hooks::Hook
      register :puma

      def dependencies_present?
        defined?(::Puma)
      end

      def install
        if ::Puma.respond_to?(:stats) && !defined?(APPSIGNAL_PUMA_PLUGIN_LOADED)
          # Only install the minutely probe if a user isn't using our Puma
          # plugin, which lives in `lib/puma/appsignal.rb`. This plugin defines
          # the {APPSIGNAL_PUMA_PLUGIN_LOADED} constant.
          #
          # We prefer people use the AppSignal Puma plugin. This fallback is
          # only there when users relied on our *magic* integration.
          #
          # Using the Puma plugin, the minutely probe thread will still run in
          # Puma workers, for other non-Puma probes, but the Puma probe only
          # runs in the Puma main process.
          # For more information:
          # https://docs.appsignal.com/ruby/integrations/puma.html
          Appsignal::Minutely.probes.register :puma, ::Appsignal::Probes::PumaProbe
        end

        return unless defined?(::Puma::Cluster)
        # For clustered mode with multiple workers
        ::Puma::Cluster.class_eval do
          alias stop_workers_without_appsignal stop_workers

          def stop_workers
            Appsignal.stop("puma cluster")
            stop_workers_without_appsignal
          end
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
appsignal-2.11.10-java lib/appsignal/hooks/puma.rb
appsignal-2.11.10 lib/appsignal/hooks/puma.rb
appsignal-2.11.9-java lib/appsignal/hooks/puma.rb
appsignal-2.11.9 lib/appsignal/hooks/puma.rb
appsignal-2.11.8-java lib/appsignal/hooks/puma.rb
appsignal-2.11.8 lib/appsignal/hooks/puma.rb
appsignal-2.11.7 lib/appsignal/hooks/puma.rb
appsignal-2.11.7-java lib/appsignal/hooks/puma.rb
appsignal-2.11.6 lib/appsignal/hooks/puma.rb
appsignal-2.11.6-java lib/appsignal/hooks/puma.rb
appsignal-2.11.5-java lib/appsignal/hooks/puma.rb
appsignal-2.11.5 lib/appsignal/hooks/puma.rb
appsignal-2.11.4-java lib/appsignal/hooks/puma.rb
appsignal-2.11.4 lib/appsignal/hooks/puma.rb
appsignal-2.11.3-java lib/appsignal/hooks/puma.rb
appsignal-2.11.3 lib/appsignal/hooks/puma.rb
appsignal-2.11.2-java lib/appsignal/hooks/puma.rb
appsignal-2.11.2 lib/appsignal/hooks/puma.rb
appsignal-2.11.1-java lib/appsignal/hooks/puma.rb
appsignal-2.11.1 lib/appsignal/hooks/puma.rb