Sha256: db45f287b826fbe9d0483db514acda9ba60c50ad726ef3bc851f576e1a1bc202

Contents?: true

Size: 1.36 KB

Versions: 20

Compression:

Stored size: 1.36 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.send(:prepend, Module.new do
          def stop_workers
            Appsignal.stop("puma cluster")
            super
          end
        end)
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
appsignal-3.0.6-java lib/appsignal/hooks/puma.rb
appsignal-3.0.6 lib/appsignal/hooks/puma.rb
appsignal-3.0.5-java lib/appsignal/hooks/puma.rb
appsignal-3.0.5 lib/appsignal/hooks/puma.rb
appsignal-3.0.4-java lib/appsignal/hooks/puma.rb
appsignal-3.0.4 lib/appsignal/hooks/puma.rb
appsignal-3.0.4.alpha.1-java lib/appsignal/hooks/puma.rb
appsignal-3.0.4.alpha.1 lib/appsignal/hooks/puma.rb
appsignal-3.0.3-java lib/appsignal/hooks/puma.rb
appsignal-3.0.3 lib/appsignal/hooks/puma.rb
appsignal-3.0.2-java lib/appsignal/hooks/puma.rb
appsignal-3.0.2 lib/appsignal/hooks/puma.rb
appsignal-3.0.1-java lib/appsignal/hooks/puma.rb
appsignal-3.0.1 lib/appsignal/hooks/puma.rb
appsignal-3.0.0-java lib/appsignal/hooks/puma.rb
appsignal-3.0.0 lib/appsignal/hooks/puma.rb
appsignal-3.0.0.rc.1 lib/appsignal/hooks/puma.rb
appsignal-3.0.0.rc.1-java lib/appsignal/hooks/puma.rb
appsignal-3.0.0.beta.1 lib/appsignal/hooks/puma.rb
appsignal-3.0.0.beta.1-java lib/appsignal/hooks/puma.rb