karafka-web 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 94f427e8f2dc9caf0e031ec3f0f4ef92185ffab89715fa91f71d620062255d45
4
- data.tar.gz: 7f0f4ea4199f73011fd06bc7d06a1282312bace48fb16abcb93d1796483977b7
3
+ metadata.gz: 9696cc8cfbcb6124155dbac2a3c92cadca69bd1acec727418874ecdd24f49de1
4
+ data.tar.gz: eb60dcbf83ba9cbd8f542b2e536e2e1c5328ee3fe358b234916575202ee75bba
5
5
  SHA512:
6
- metadata.gz: d7a31d203b3574955215a391f6be9538d2e31cc67a749fc63fa969288b2826a033d8b50532214649b5d0a9a682fecc166f1551d249219e731b90f69cdc98ef19
7
- data.tar.gz: 6d9824c76559fc2903985152d6a94a3936b03c9c3c22283daf5a748bd2d140a5ba25d344dc55f745f66553f78086f96cde36e4db2104055b3ae01a5c106059b9
6
+ metadata.gz: 133ecc3adc65e9559a317b4148813b95f21a41150a271f754e726d2617f19515e89498322b0b50e808825a9793a78472041618c584aaf3797e80259a2f296782
7
+ data.tar.gz: bf07811d4f0825f0c9770ae04218c2d73c24eed397296ae54fbeb5f8898a6db750952588426ad45ded5c88d9ce498b3aadf54a202852f4ec8193fd9ff4a159d3
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Karafka Web changelog
2
2
 
3
+ ## 0.5.2 (2023-05-22)
4
+ - Label ActiveJob consumers jobs with `active_job` tag.
5
+ - Label Virtual Partitions consumers with `virtual` tag.
6
+ - Label Long Running Jobs with `long_running_job` tag.
7
+ - Label collapsed Virtual Partition with `collapsed` tag.
8
+ - Display consumer tags always below the consumer class name in Jobs/Consumer Jobs views.
9
+ - Add label with the attempt count on work being retried.
10
+
3
11
  ## 0.5.1 (2023-04-16)
4
12
  - [Fix] Use CSP header matching Sidekiq one to ensure styles and js loading (#55)
5
13
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- karafka-web (0.5.1)
4
+ karafka-web (0.5.2)
5
5
  erubi (~> 1.4)
6
6
  karafka (>= 2.0.40, < 3.0.0)
7
7
  karafka-core (>= 2.0.12, < 3.0.0)
@@ -24,9 +24,9 @@ GEM
24
24
  factory_bot (6.2.1)
25
25
  activesupport (>= 5.0.0)
26
26
  ffi (1.15.5)
27
- i18n (1.12.0)
27
+ i18n (1.13.0)
28
28
  concurrent-ruby (~> 1.0)
29
- karafka (2.0.40)
29
+ karafka (2.0.41)
30
30
  karafka-core (>= 2.0.12, < 3.0.0)
31
31
  thor (>= 0.20)
32
32
  waterdrop (>= 2.4.10, < 3.0.0)
@@ -38,7 +38,7 @@ GEM
38
38
  ffi (~> 1.15)
39
39
  mini_portile2 (~> 2.6)
40
40
  rake (> 12)
41
- mini_portile2 (2.8.1)
41
+ mini_portile2 (2.8.2)
42
42
  minitest (5.18.0)
43
43
  rack (3.0.7)
44
44
  rackup (0.2.3)
@@ -51,9 +51,9 @@ GEM
51
51
  rspec-core (~> 3.12.0)
52
52
  rspec-expectations (~> 3.12.0)
53
53
  rspec-mocks (~> 3.12.0)
54
- rspec-core (3.12.1)
54
+ rspec-core (3.12.2)
55
55
  rspec-support (~> 3.12.0)
56
- rspec-expectations (3.12.2)
56
+ rspec-expectations (3.12.3)
57
57
  diff-lcs (>= 1.2.0, < 2.0)
58
58
  rspec-support (~> 3.12.0)
59
59
  rspec-mocks (3.12.5)
@@ -70,14 +70,13 @@ GEM
70
70
  tilt (2.1.0)
71
71
  tzinfo (2.0.6)
72
72
  concurrent-ruby (~> 1.0)
73
- waterdrop (2.5.1)
73
+ waterdrop (2.5.2)
74
74
  karafka-core (>= 2.0.12, < 3.0.0)
75
75
  zeitwerk (~> 2.3)
76
76
  webrick (1.8.1)
77
- zeitwerk (2.6.7)
77
+ zeitwerk (2.6.8)
78
78
 
79
79
  PLATFORMS
80
- arm64-darwin-21
81
80
  x86_64-linux
82
81
 
83
82
  DEPENDENCIES
@@ -45,7 +45,8 @@ module Karafka
45
45
  Tracking::Consumers::Listeners::Errors.new,
46
46
  Tracking::Consumers::Listeners::Statistics.new,
47
47
  Tracking::Consumers::Listeners::Pausing.new,
48
- Tracking::Consumers::Listeners::Processing.new
48
+ Tracking::Consumers::Listeners::Processing.new,
49
+ Tracking::Consumers::Listeners::Tags.new
49
50
  ]
50
51
  end
51
52
 
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Karafka
4
+ module Web
5
+ module Tracking
6
+ module Consumers
7
+ module Listeners
8
+ # Listener used to attach tags to consumers for Web-UI usage. Those tags will be picked
9
+ # up by another listener
10
+ #
11
+ # @note We cannot attach here certain the ActiveJob consumer tags and they need to be
12
+ # in Karafka itself (mainly the per AJ job tag) because from the outside consumer
13
+ # perspective we have a single consumption that can run multiple different AJ jobs
14
+ #
15
+ # @note We can assign tags here and the order of tracking listeners does not matter,
16
+ # because tags state for consumers is materialized in the moment of reporting.
17
+ class Tags < Base
18
+ # @param event [Karafka::Core::Monitoring::Event]
19
+ def on_consumer_consume(event)
20
+ consumer = event.payload[:caller]
21
+
22
+ tag_active_job(consumer)
23
+ tag_attempt(consumer)
24
+
25
+ return unless Karafka.pro?
26
+
27
+ tag_virtual_partitions(consumer)
28
+ tag_long_running_job(consumer)
29
+ end
30
+
31
+ private
32
+
33
+ # Adds ActiveJob consumer related tags
34
+ #
35
+ # @param consumer [Karafka::BaseConsumer]
36
+ def tag_active_job(consumer)
37
+ return unless consumer.topic.active_job?
38
+
39
+ consumer.tags.add(:active_job, :active_job)
40
+ end
41
+
42
+ # Adds attempts counter if this is not the first attempt. Not the first means, there
43
+ # was an error and we are re-processing.
44
+ #
45
+ # @param consumer [Karafka::BaseConsumer]
46
+ def tag_attempt(consumer)
47
+ attempt = consumer.coordinator.pause_tracker.attempt
48
+
49
+ if attempt > 1
50
+ consumer.tags.add(:attempt, "attempt:#{attempt}")
51
+ else
52
+ consumer.tags.delete(:attempt)
53
+ end
54
+ end
55
+
56
+ # Tags virtual partitioned consumers and adds extra info if operates in a collapsed
57
+ # mode
58
+ #
59
+ # @param consumer [Karafka::BaseConsumer]
60
+ def tag_virtual_partitions(consumer)
61
+ return unless consumer.topic.virtual_partitions?
62
+
63
+ consumer.tags.add(:virtual, :virtual)
64
+
65
+ if consumer.collapsed?
66
+ consumer.tags.add(:collapsed, :collapsed)
67
+ else
68
+ consumer.tags.delete(:collapsed)
69
+ end
70
+ end
71
+
72
+ # Tags long running job consumer work
73
+ #
74
+ # @param consumer [Karafka::BaseConsumer]
75
+ def tag_long_running_job(consumer)
76
+ return unless consumer.topic.long_running_job?
77
+
78
+ consumer.tags.add(:long_running_job, :long_running)
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -2,8 +2,9 @@
2
2
  <td>
3
3
  <code><%= job.consumer %></code>
4
4
 
5
- <% job.tags.each do |tag| %>
6
- <span class="badge bg-info"><%= tag %></span>
5
+ <% unless job.tags.empty? %>
6
+ <br/>
7
+ <%== tags(job.tags) %>
7
8
  <% end %>
8
9
  </td>
9
10
  <td>
@@ -13,7 +13,10 @@
13
13
  <td>
14
14
  <code><%= job.consumer %></code>
15
15
 
16
- <%== tags(job.tags) %>
16
+ <% unless job.tags.empty? %>
17
+ <br/>
18
+ <%== tags(job.tags) %>
19
+ <% end %>
17
20
  </td>
18
21
  <td>
19
22
  <code>#<%= job.type %></code>
@@ -13,7 +13,10 @@
13
13
  <td>
14
14
  <code><%= job.consumer %></code>
15
15
 
16
- <%== tags(job.tags) %>
16
+ <% unless job.tags.empty? %>
17
+ <br/>
18
+ <%== tags(job.tags) %>
19
+ <% end %>
17
20
  </td>
18
21
  <td>
19
22
  <code>#<%= job.type %></code>
@@ -3,6 +3,6 @@
3
3
  module Karafka
4
4
  module Web
5
5
  # Current gem version
6
- VERSION = '0.5.1'
6
+ VERSION = '0.5.2'
7
7
  end
8
8
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: karafka-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Mensfeld
@@ -35,7 +35,7 @@ cert_chain:
35
35
  Qf04B9ceLUaC4fPVEz10FyobjaFoY4i32xRto3XnrzeAgfEe4swLq8bQsR3w/EF3
36
36
  MGU0FeSV2Yj7Xc2x/7BzLK8xQn5l7Yy75iPF+KP3vVmDHnNl
37
37
  -----END CERTIFICATE-----
38
- date: 2023-04-16 00:00:00.000000000 Z
38
+ date: 2023-05-22 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: erubi
@@ -184,6 +184,7 @@ files:
184
184
  - lib/karafka/web/tracking/consumers/listeners/processing.rb
185
185
  - lib/karafka/web/tracking/consumers/listeners/statistics.rb
186
186
  - lib/karafka/web/tracking/consumers/listeners/status.rb
187
+ - lib/karafka/web/tracking/consumers/listeners/tags.rb
187
188
  - lib/karafka/web/tracking/consumers/sampler.rb
188
189
  - lib/karafka/web/tracking/memoized_shell.rb
189
190
  - lib/karafka/web/tracking/reporter.rb
metadata.gz.sig CHANGED
Binary file