Class: Karafka::Web::Pro::Commanding::Commands::Consumers::Trace

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

Overview

Collects all backtraces from the available Ruby threads and publishes their details

back to Kafka for debug.

Instance Attribute Summary

Attributes inherited from Base

#command

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Karafka::Web::Pro::Commanding::Commands::Base

Instance Method Details

#callObject

Runs tracing and publishes result back to Kafka



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/karafka/web/pro/commanding/commands/consumers/trace.rb', line 44

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

  result(threads)
end