Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename probing to tracing #445

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 0.10.3 (Unreleased)
- **[Feature]** Introduce ability to brand Web UI with environment (Pro).
- [Enhancement] Support schedule cancellation via Web UI.
- [Enhancement] Rename "probing" to "tracing" to better reflect what this commanding option does.
- [Fix] Fix not working primary and secondary alert styles.

## 0.10.2 (2024-09-03)
Expand Down
2 changes: 1 addition & 1 deletion lib/karafka/web/pro/commanding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module Web
module Pro
# Namespace for things related to consumers commanding (management)
#
# This feature allows for basic of consumers. They can be stopped, moved to quiet or probed
# This feature allows for basic of consumers. They can be stopped, moved to quiet or traced
# via the Web UI
module Commanding
class << self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ module Commanding
module Commands
# Collects all backtraces from the available Ruby threads and publishes their details
# back to Kafka for debug.
class Probe < Base
# Runs probing and publishes result back to Kafka
class Trace < Base
# Runs tracing and publishes result back to Kafka
def call
threads = {}

Expand All @@ -31,7 +31,7 @@ def call
t_d[:backtrace] = (thread.backtrace || ['<no backtrace available>']).join("\n")
end

Dispatcher.result(threads, process_id, 'probe')
Dispatcher.result(threads, process_id, 'trace')
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/karafka/web/pro/commanding/listener.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module Web
module Pro
# Namespace for things related to consumers commanding (management)
#
# This feature allows for basic of consumers. They can be stopped, moved to quiet or probed
# This feature allows for basic of consumers. They can be stopped, moved to quiet or traced
# via the Web UI
module Commanding
# Wrapper around the Pro Iterator that yields messages with commands when needed for
Expand Down
4 changes: 2 additions & 2 deletions lib/karafka/web/pro/commanding/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ def call
# @param command [String] command expected to run
def control(command)
case command
when 'probe'
Commands::Probe.new.call
when 'trace'
Commands::Trace.new.call
when 'stop'
Commands::Stop.new.call
when 'quiet'
Expand Down
4 changes: 2 additions & 2 deletions lib/karafka/web/pro/ui/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ class App < Web::Ui::Base
end

r.on String do |process_id|
r.post 'probe' do
controller.probe(process_id)
r.post 'trace' do
controller.trace(process_id)
end

r.post 'quiet' do
Expand Down
8 changes: 4 additions & 4 deletions lib/karafka/web/pro/ui/controllers/commanding_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ module Controllers
# Controller responsible for handling requests that should trigger some action on the
# consumers.
class CommandingController < BaseController
# Dispatches the probe request to a given process
# Dispatches the trace request to a given process
#
# @param process_id [String]
def probe(process_id)
command(:probe, process_id)
def trace(process_id)
command(:trace, process_id)

redirect(
:back,
success: dispatched_to_one(:probe, process_id)
success: dispatched_to_one(:trace, process_id)
)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/karafka/web/pro/ui/views/commands/_command.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<td>
<%
color = case command[:command][:name]
when 'probe'
when 'trace'
'info'
when 'quiet'
'warning'
Expand Down
6 changes: 3 additions & 3 deletions lib/karafka/web/pro/ui/views/consumers/_consumer_controls.erb
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@

<td class="commands-inline-3">
<%
probe_path = root_path('commanding', process.id, 'probe')
trace_path = root_path('commanding', process.id, 'trace')
disabled_class = process.status != 'stopped' ? '' : 'btn-disabled'
%>
<form action="<%= probe_path %>" method="post" class="inline" title="Probe">
<%== csrf_tag(probe_path) %>
<form action="<%= trace_path %>" method="post" class="inline" title="Trace">
<%== csrf_tag(trace_path) %>

<button type="submit" class="btn btn-info btn-sm <%= disabled_class %>">
<%== icon(:gear) %>
Expand Down
8 changes: 4 additions & 4 deletions lib/karafka/web/pro/ui/views/consumers/consumer/_commands.erb
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<% if Karafka::Web.config.commanding.active && !process.tags.include?('embedded') %>
<div class="col-span-12 flex justify-end space-x-2 mb-6">
<%
probe_path = root_path('commanding', process.id, 'probe')
trace_path = root_path('commanding', process.id, 'trace')
disabled_class = process.status != 'stopped' ? '' : 'btn-disabled'
%>
<form
action="<%= probe_path %>"
action="<%= trace_path %>"
method="post"
class="inline-flex items-center"
>
<%== csrf_tag(probe_path) %>
<%== csrf_tag(trace_path) %>
<button
type="submit"
class="btn btn-info btn-sm <%= disabled_class %>"
>
<%== icon(:gear) %>
Probe
Trace
</button>
</form>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"schema_version": "1.0.0",
"type": "command",
"command": {
"name": "probe"
"name": "trace"
},
"dispatched_at": 1712518179.6275373,
"process": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"schema_version": "1.0.0",
"type": "result",
"command": {
"name": "probe"
"name": "trace"
},
"result": {
"8l51": {
Expand All @@ -15,7 +15,7 @@
},
"8ly9": {
"label": "Thread TID-8ly9 karafka.web.pro.commanding.manager",
"backtrace": "/mnt/software/Karafka/karafka-web/lib/karafka/web/pro/commanding/manager.rb:126:in `backtrace'\n/mnt/software/Karafka/karafka-web/lib/karafka/web/pro/commanding/manager.rb:126:in `block in probe'\n/mnt/software/Karafka/karafka-web/lib/karafka/web/pro/commanding/manager.rb:122:in `each'\n/mnt/software/Karafka/karafka-web/lib/karafka/web/pro/commanding/manager.rb:122:in `probe'\n/mnt/software/Karafka/karafka-web/lib/karafka/web/pro/commanding/manager.rb:105:in `control'\n/mnt/software/Karafka/karafka-web/lib/karafka/web/pro/commanding/manager.rb:81:in `block in call'\n/mnt/software/Karafka/karafka/lib/karafka/pro/iterator.rb:91:in `block in each'\n/mnt/software/Karafka/karafka/lib/karafka/admin.rb:395:in `with_consumer'\n/mnt/software/Karafka/karafka/lib/karafka/pro/iterator.rb:73:in `each'\n/mnt/software/Karafka/karafka-web/lib/karafka/web/pro/commanding/manager.rb:75:in `call'\n/mnt/software/Karafka/karafka/lib/karafka/helpers/async.rb:40:in `block (2 levels) in async_call'"
"backtrace": "/mnt/software/Karafka/karafka-web/lib/karafka/web/pro/commanding/manager.rb:126:in `backtrace'\n/mnt/software/Karafka/karafka-web/lib/karafka/web/pro/commanding/manager.rb:126:in `block in trace'\n/mnt/software/Karafka/karafka-web/lib/karafka/web/pro/commanding/manager.rb:122:in `each'\n/mnt/software/Karafka/karafka-web/lib/karafka/web/pro/commanding/manager.rb:122:in `trace'\n/mnt/software/Karafka/karafka-web/lib/karafka/web/pro/commanding/manager.rb:105:in `control'\n/mnt/software/Karafka/karafka-web/lib/karafka/web/pro/commanding/manager.rb:81:in `block in call'\n/mnt/software/Karafka/karafka/lib/karafka/pro/iterator.rb:91:in `block in each'\n/mnt/software/Karafka/karafka/lib/karafka/admin.rb:395:in `with_consumer'\n/mnt/software/Karafka/karafka/lib/karafka/pro/iterator.rb:73:in `each'\n/mnt/software/Karafka/karafka-web/lib/karafka/web/pro/commanding/manager.rb:75:in `call'\n/mnt/software/Karafka/karafka/lib/karafka/helpers/async.rb:40:in `block (2 levels) in async_call'"
},
"8lyt": {
"label": "Thread TID-8lyt karafka.web.tracking.scheduler",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

RSpec.describe_current do
subject(:probe_command) { described_class.new }
subject(:trace_command) { described_class.new }

let(:dispatcher) { Karafka::Web::Pro::Commanding::Dispatcher }
let(:test_thread) { Thread.new { sleep(0.5) } }
Expand All @@ -19,12 +19,12 @@
end

it 'expect to collect and publish threads backtraces to Kafka' do
probe_command.call
trace_command.call

expect(dispatcher).to have_received(:result) do |threads_info, pid, action|
expect(threads_info).to be_a(Hash)
expect(pid).to include(mock_pid.to_s)
expect(action).to eq('probe')
expect(action).to eq('trace')

thread_info = threads_info.values.first
expect(thread_info[:label]).to include('Thread TID-')
Expand All @@ -36,12 +36,12 @@
before { allow(Karafka::Process).to receive(:tags).and_return(%w[embedded]) }

it 'expect to handle it without any issues' do
probe_command.call
trace_command.call

expect(dispatcher).to have_received(:result) do |threads_info, pid, action|
expect(threads_info).to be_a(Hash)
expect(pid).to include(mock_pid.to_s)
expect(action).to eq('probe')
expect(action).to eq('trace')

thread_info = threads_info.values.first
expect(thread_info[:label]).to include('Thread TID-')
Expand Down
14 changes: 7 additions & 7 deletions spec/lib/karafka/web/pro/commanding/manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@
allow(matcher).to receive(:matches?).with(message).and_return(true)
end

context 'when command is probe' do
let(:probe_command) { Karafka::Web::Pro::Commanding::Commands::Probe.new }
let(:command_name) { 'probe' }
context 'when command is trace' do
let(:trace_command) { Karafka::Web::Pro::Commanding::Commands::Trace.new }
let(:command_name) { 'trace' }

before do
allow(probe_command.class).to receive(:new).and_return(probe_command)
allow(probe_command).to receive(:call)
allow(trace_command.class).to receive(:new).and_return(trace_command)
allow(trace_command).to receive(:call)
end

it 'executes probe command' do
it 'executes trace command' do
manager.send(:call)
expect(probe_command).to have_received(:call)
expect(trace_command).to have_received(:call)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

before { topics_config.consumers.commands = commands_topic }

describe '#probe' do
before { post "commanding/#{process_id}/probe" }
describe '#trace' do
before { post "commanding/#{process_id}/trace" }

it do
expect(response.status).to eq(302)
Expand All @@ -25,7 +25,7 @@
expect(message.payload[:schema_version]).to eq('1.0.0')
expect(message.payload[:type]).to eq('command')
expect(message.payload[:dispatched_at]).not_to be_nil
expect(message.payload[:command]).to eq(name: 'probe')
expect(message.payload[:command]).to eq(name: 'trace')
expect(message.payload[:process]).to eq(id: process_id)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@

34.times do
%w[
probe
trace
stop
quiet
].each do |type|
Expand All @@ -102,7 +102,7 @@
expect(body).not_to include(support_message)
expect(body).to include('commands/99')
expect(body).to include('<a href="/consumers/')
expect(body).to include('probe')
expect(body).to include('trace')
expect(body).to include('quiet')
expect(body).to include('stop')
end
Expand All @@ -118,7 +118,7 @@
expect(body).to include('commands/53')
expect(body).not_to include('commands/99')
expect(body).to include('<a href="/consumers/')
expect(body).to include('probe')
expect(body).to include('trace')
expect(body).to include('quiet')
expect(body).to include('stop')
expect(body).not_to include(support_message)
Expand Down Expand Up @@ -151,7 +151,7 @@
end

%w[
probe
trace
quiet
stop
quiet_all
Expand Down Expand Up @@ -199,10 +199,10 @@
end
end

context 'when visiting probe result' do
context 'when visiting trace result' do
before do
topics_config.consumers.commands = commands_topic
produce(commands_topic, Fixtures.consumers_commands_file('v1.0.0_probe_result.json'))
produce(commands_topic, Fixtures.consumers_commands_file('v1.0.0_trace_result.json'))
get 'commands/0'
end

Expand All @@ -214,15 +214,15 @@
expect(body).not_to include(incompatible_message)
expect(body).to include('rb:539:in `rd_kafka_consumer_poll')
expect(body).to include('Metadata')
expect(body).to include('probe result')
expect(body).to include('trace result')
expect(body).to include('/consumers/shinra:397793:6fa3f39acf46')
end
end

context 'when visiting probe result that is not with a compatible schema' do
context 'when visiting trace result that is not with a compatible schema' do
before do
topics_config.consumers.commands = commands_topic
data = Fixtures.consumers_commands_json('v1.0.0_probe_result')
data = Fixtures.consumers_commands_json('v1.0.0_trace_result')
data[:schema_version] = '0.0.1'
produce(commands_topic, data.to_json)
get 'commands/0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@
expect(body).to include('Performance')
expect(body).to include('Quiet All')
expect(body).to include('Stop All')
expect(body).to include('Probe')
expect(body).to include('Trace')
end

context 'when sorting' do
Expand Down Expand Up @@ -489,7 +489,7 @@
expect(body).to include('Performance')
expect(body).to include('Quiet All')
expect(body).to include('Stop All')
expect(body).to include('Probe')
expect(body).to include('Trace')
expect(body).to include('title="Supported only in standalone consumer processes"')
end

Expand Down Expand Up @@ -531,7 +531,7 @@
expect(body).to include('Performance')
expect(body).to include('Quiet All')
expect(body).to include('Stop All')
expect(body).to include('Probe')
expect(body).to include('Trace')
expect(body).to include('title="Supported only in standalone consumer processes"')
end

Expand Down Expand Up @@ -566,7 +566,7 @@
expect(body).to include('Performance')
expect(body).to include('Quiet All')
expect(body).to include('Stop All')
expect(body).to include('Probe')
expect(body).to include('Trace')
end
end

Expand Down Expand Up @@ -660,7 +660,7 @@

it do
expect(response).to be_ok
expect(body).to include('Probe')
expect(body).to include('Trace')
expect(body).to include('Quiet')
expect(body).to include('Stop')
end
Expand All @@ -675,7 +675,7 @@

it do
expect(response).to be_ok
expect(body).not_to include('Probe')
expect(body).not_to include('Trace')
expect(body).not_to include('Quiet')
expect(body).not_to include('Stop')
end
Expand Down