Sha256: c2fad9e22bccbc8e40d3e5f24156c132ae4ebe1acb8832dee435675c35dde5ef

Contents?: true

Size: 1.08 KB

Versions: 26

Compression:

Stored size: 1.08 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 [Karafka::Core::Monitoring::Event] event details including payload
      def on_app_initializing(_event)
        setproctitle('initializing')
      end

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

      # Updates proc title to a stopping one
      # @param _event [Karafka::Core::Monitoring::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

26 entries across 26 versions & 1 rubygems

Version Path
karafka-2.0.24 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.23 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.22 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.21 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.20 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.19 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.18 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.17 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.16 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.15 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.14 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.13 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.12 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.11 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.10 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.9 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.8 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.7 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.6 lib/karafka/instrumentation/proctitle_listener.rb
karafka-2.0.5 lib/karafka/instrumentation/proctitle_listener.rb