Class: Karafka::Web::Pro::Commanding::Commands::Probe

Inherits:
Base
  • Object
show all
Defined in:
lib/karafka/web/pro/commanding/commands/probe.rb

Overview

Collects all backtraces from the available Ruby threads and publishes their details back to Kafka for debug.

Instance Method Summary collapse

Instance Method Details

#callObject

Runs probing and publishes result back to Kafka



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/karafka/web/pro/commanding/commands/probe.rb', line 24

def call
  threads = {}

  Thread.list.each do |thread|
    tid = (thread.object_id ^ ::Process.pid).to_s(36)
    t_d = threads[tid] = {}
    t_d[:label] = "Thread TID-#{tid} #{thread.name}"
    t_d[:backtrace] = (thread.backtrace || ['<no backtrace available>']).join("\n")
  end

  Dispatcher.result(threads, process_id, 'probe')
end