Sha256: d44fc85a9cc97a943a47838f1959ff8f2dbba976d3ba4be96d85e24e1396ba5b

Contents?: true

Size: 1.04 KB

Versions: 43

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module Karafka
  module Instrumentation
    # Listener that sets a proc title with a nice descriptive value
    class ProctitleListener
      # Updates proc title to an initializing one
      # @param _event [Dry::Events::Event] event details including payload
      def on_app_initializing(_event)
        setproctitle('initializing')
      end

      # Updates proc title to a running one
      # @param _event [Dry::Events::Event] event details including payload
      def on_app_running(_event)
        setproctitle('running')
      end

      # Updates proc title to a stopping one
      # @param _event [Dry::Events::Event] event details including payload
      def on_app_stopping(_event)
        setproctitle('stopping')
      end

      private

      # Sets a proper proc title with our constant prefix
      # @param status [String] any status we want to set
      def setproctitle(status)
        ::Process.setproctitle(
          "karafka #{Karafka::App.config.client_id} (#{status})"
        )
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
karafka-1.4.15 lib/karafka/instrumentation/proctitle_listener.rb
karafka-1.4.14 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.0.rc5 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.0.rc4 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.0.rc3 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.0.rc2 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.0.rc1 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.0.beta5 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.0.beta4 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.0.beta3 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.0.beta2 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.0.beta1 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.0.alpha6 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.0.alpha5 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.0.alpha4 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.0.alpha3 lib/karafka/instrumentation/proctitle_listener.rb
karafka-1.4.13 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.0.alpha2 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.0.alpha1 lib/karafka/instrumentation/proctitle_listener.rb
karafka-1.4.12 lib/karafka/instrumentation/proctitle_listener.rb