karafka-web 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/CHANGELOG.md +17 -1
  4. data/Gemfile +1 -0
  5. data/Gemfile.lock +23 -11
  6. data/bin/karafka-web +1 -26
  7. data/karafka-web.gemspec +2 -2
  8. data/lib/karafka/web/cli.rb +80 -0
  9. data/lib/karafka/web/config.rb +5 -0
  10. data/lib/karafka/web/installer.rb +65 -29
  11. data/lib/karafka/web/processing/consumer.rb +2 -1
  12. data/lib/karafka/web/tracking/consumers/contracts/job.rb +1 -0
  13. data/lib/karafka/web/tracking/consumers/contracts/report.rb +1 -0
  14. data/lib/karafka/web/tracking/consumers/listeners/errors.rb +1 -1
  15. data/lib/karafka/web/tracking/consumers/listeners/processing.rb +2 -1
  16. data/lib/karafka/web/tracking/consumers/sampler.rb +9 -3
  17. data/lib/karafka/web/tracking/reporter.rb +2 -1
  18. data/lib/karafka/web/ui/app.rb +5 -0
  19. data/lib/karafka/web/ui/controllers/status.rb +23 -0
  20. data/lib/karafka/web/ui/models/process.rb +7 -0
  21. data/lib/karafka/web/ui/models/status.rb +169 -0
  22. data/lib/karafka/web/ui/pro/app.rb +5 -0
  23. data/lib/karafka/web/ui/pro/controllers/status.rb +26 -0
  24. data/lib/karafka/web/ui/pro/views/consumers/_consumer.erb +15 -7
  25. data/lib/karafka/web/ui/pro/views/consumers/consumer/_job.erb +4 -0
  26. data/lib/karafka/web/ui/pro/views/consumers/consumer/_metrics.erb +10 -0
  27. data/lib/karafka/web/ui/pro/views/jobs/_job.erb +4 -0
  28. data/lib/karafka/web/ui/pro/views/shared/_navigation.erb +5 -0
  29. data/lib/karafka/web/ui/views/consumers/_consumer.erb +15 -7
  30. data/lib/karafka/web/ui/views/jobs/_job.erb +4 -0
  31. data/lib/karafka/web/ui/views/shared/_navigation.erb +5 -0
  32. data/lib/karafka/web/ui/views/shared/exceptions/not_found.erb +2 -0
  33. data/lib/karafka/web/ui/views/status/_breadcrumbs.erb +5 -0
  34. data/lib/karafka/web/ui/views/status/_failure.erb +14 -0
  35. data/lib/karafka/web/ui/views/status/_halted.erb +11 -0
  36. data/lib/karafka/web/ui/views/status/_success.erb +11 -0
  37. data/lib/karafka/web/ui/views/status/failures/_connection.erb +7 -0
  38. data/lib/karafka/web/ui/views/status/failures/_initial_state.erb +20 -0
  39. data/lib/karafka/web/ui/views/status/failures/_live_reporting.erb +7 -0
  40. data/lib/karafka/web/ui/views/status/failures/_partitions.erb +19 -0
  41. data/lib/karafka/web/ui/views/status/failures/_state_calculation.erb +8 -0
  42. data/lib/karafka/web/ui/views/status/failures/_topics.erb +20 -0
  43. data/lib/karafka/web/ui/views/status/show.erb +94 -0
  44. data/lib/karafka/web/version.rb +1 -1
  45. data/lib/karafka/web.rb +0 -6
  46. data.tar.gz.sig +0 -0
  47. metadata +21 -6
  48. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ffbcae8c8e094bdd72518fa41694bb9b6b658c713010ca09ff9f3ca8f857666
4
- data.tar.gz: 4e9d38e683197bb003afb3732e333a19d603e2b8fd3e8ff4fa7b8d0d1cc5f3c3
3
+ metadata.gz: eb17bd9d46e6fa0d0125bc665bff74a9d4277be394f1bf29223b6d49ef09e054
4
+ data.tar.gz: 2f1da7d4fa79116a67ae3300863b56c3ac2215d80dccba89520e33e78c3b1a84
5
5
  SHA512:
6
- metadata.gz: ba7f91646a8062b56380afe9ccde45802c18c12d5a7581fce4b99db24480b730aa0f9743af825dd24006725424887f63cf5a2dbf17d32c541d7a4df83f823c34
7
- data.tar.gz: 19084a9683d9d8023fbef859a428d418a375c2b44d588ad9d065de6e2a89f913cc505258836f717c2e5a095e3a0d76b15d0d2d6c23df95682d41e042ec1d16f8
6
+ metadata.gz: cc9f331aa0b9276c1b3c2d6d4f400b9d8600da174123d472b1699554e0cd95de14ff60b7c4effbb0c4f86a423f24ff27f5facc282ff8215863c146a4b1c0bb41
7
+ data.tar.gz: 1f638b2ca877b1b34612654a19f0fb8d04ab88e5dc6b560a7090e74a6d1202da0257d4f941f8f182b6b874d8a099db30772a1ab9517b32ebae76161d9314797a
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,8 +1,24 @@
1
1
  # Karafka Web changelog
2
2
 
3
+ ## 0.2.0 (2023-02-24)
4
+ - **[Feature]** Introduce ability to tag `Karafka::Process` to display process-centric tags in the Web UI.
5
+ - **[Feature]** Introduce ability to tag consumer instances to display consumption-centric tags in the Web UI.
6
+ - **[Feature]** Introduce a /status page that can validate the setup and tell what is missing (#1318)
7
+ - [Improvement] Allow for disabling the consumer subscription from Web for multi-tenant Web UI usage (#1331)
8
+ - [Improvement] Make sure that states and reports are always dispatched to the partition `0`. This should prevent UI from not fully working when someone accidentally creates more partitions than expected.
9
+ - [Fix] Fix a bug where bootstrapping would create two initial states.
10
+ - [Fix] Fix a case, where errors listener would try to force encoding on a frozen error message.
11
+
12
+ ## 0.1.3 (2023-02-14)
13
+ - Skip topics creation if web topics already exist (do not raise error)
14
+ - Support ability to provide replication factor in the install command
15
+ - Provide ability to reset the state with a `reset` command. It will remove and re-create the topics.
16
+ - Provide ability to uninstall the web via the CLI `uninstall` command
17
+ - Remove the `Karafka::Web.bootstrap!` method as the install should happen via `bundle exec karafka-web install`
18
+
3
19
  ## 0.1.2 (2023-02-10)
4
20
  - Provide more comprehensive info when lag stored and stored offset are not available.
5
- - Setup rspec scaffold
21
+ - Setup rspec scaffold.
6
22
 
7
23
  ## 0.1.1 (2023-01-30)
8
24
  - Rename `Karafka::Web.bootstrap_topics!` to `Karafka::Web.bootstrap!` and expand it with the zero state injection.
data/Gemfile CHANGED
@@ -8,6 +8,7 @@ gemspec
8
8
 
9
9
  group :test do
10
10
  gem 'byebug'
11
+ gem 'factory_bot'
11
12
  gem 'rspec'
12
13
  gem 'simplecov'
13
14
  end
data/Gemfile.lock CHANGED
@@ -1,41 +1,51 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- karafka-web (0.1.2)
4
+ karafka-web (0.2.0)
5
5
  erubi (~> 1.4)
6
- karafka (>= 2.0.29, < 3.0.0)
7
- karafka-core (>= 2.0.10, < 3.0.0)
6
+ karafka (>= 2.0.33, < 3.0.0)
7
+ karafka-core (>= 2.0.12, < 3.0.0)
8
8
  roda (~> 3.63)
9
9
  tilt (~> 2.0)
10
10
 
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
+ activesupport (7.0.4.2)
15
+ concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ i18n (>= 1.6, < 2)
17
+ minitest (>= 5.1)
18
+ tzinfo (~> 2.0)
14
19
  byebug (11.1.3)
15
20
  concurrent-ruby (1.2.0)
16
21
  diff-lcs (1.5.0)
17
22
  docile (1.4.0)
18
23
  erubi (1.12.0)
24
+ factory_bot (6.2.1)
25
+ activesupport (>= 5.0.0)
19
26
  ffi (1.15.5)
20
- karafka (2.0.30)
21
- karafka-core (>= 2.0.9, < 3.0.0)
27
+ i18n (1.12.0)
28
+ concurrent-ruby (~> 1.0)
29
+ karafka (2.0.33)
30
+ karafka-core (>= 2.0.12, < 3.0.0)
22
31
  thor (>= 0.20)
23
32
  waterdrop (>= 2.4.10, < 3.0.0)
24
33
  zeitwerk (~> 2.3)
25
- karafka-core (2.0.10)
34
+ karafka-core (2.0.12)
26
35
  concurrent-ruby (>= 1.1)
27
- karafka-rdkafka (>= 0.12)
28
- karafka-rdkafka (0.12.0)
36
+ karafka-rdkafka (>= 0.12.1)
37
+ karafka-rdkafka (0.12.1)
29
38
  ffi (~> 1.15)
30
39
  mini_portile2 (~> 2.6)
31
40
  rake (> 12)
32
41
  mini_portile2 (2.8.1)
42
+ minitest (5.17.0)
33
43
  rack (3.0.4.1)
34
44
  rackup (0.2.3)
35
45
  rack (>= 3.0.0.beta1)
36
46
  webrick
37
47
  rake (13.0.6)
38
- roda (3.64.0)
48
+ roda (3.65.0)
39
49
  rack
40
50
  rspec (3.12.0)
41
51
  rspec-core (~> 3.12.0)
@@ -57,7 +67,9 @@ GEM
57
67
  simplecov-html (0.12.3)
58
68
  simplecov_json_formatter (0.1.4)
59
69
  thor (1.2.1)
60
- tilt (2.0.11)
70
+ tilt (2.1.0)
71
+ tzinfo (2.0.6)
72
+ concurrent-ruby (~> 1.0)
61
73
  waterdrop (2.4.10)
62
74
  karafka-core (>= 2.0.9, < 3.0.0)
63
75
  zeitwerk (~> 2.3)
@@ -65,11 +77,11 @@ GEM
65
77
  zeitwerk (2.6.7)
66
78
 
67
79
  PLATFORMS
68
- arm64-darwin-21
69
80
  x86_64-linux
70
81
 
71
82
  DEPENDENCIES
72
83
  byebug
84
+ factory_bot
73
85
  karafka-web!
74
86
  rackup (~> 0.2)
75
87
  rspec
data/bin/karafka-web CHANGED
@@ -4,30 +4,5 @@ require 'karafka'
4
4
  require 'karafka/web'
5
5
 
6
6
  ::Karafka::Cli::Base.load
7
- include ::Karafka::Helpers::Colorize
8
7
 
9
- case ARGV[0]
10
- when 'install'
11
- puts
12
- puts 'Installing Karafka Web UI...'
13
- puts
14
- puts 'Creating necessary topics and populating state data...'
15
- Karafka::Web.bootstrap!
16
- puts 'Updating the Karafka boot file...'
17
-
18
- enabler = 'Karafka::Web.enable!'
19
-
20
- if File.read(Karafka.boot_file).include?(enabler)
21
- puts "Web UI #{green('already')} installed."
22
- else
23
- File.open(Karafka.boot_file, 'a') do |f|
24
- f << "\n#{enabler}\n"
25
- end
26
- end
27
-
28
- puts
29
- puts("Installation #{green('completed')}. Have fun!")
30
- puts
31
- else
32
- raise NotImplementedError, "#{ARGV[0]} is not supported"
33
- end
8
+ ::Karafka::Web::Cli.start
data/karafka-web.gemspec CHANGED
@@ -17,8 +17,8 @@ Gem::Specification.new do |spec|
17
17
  spec.licenses = %w[LGPL-3.0 Commercial]
18
18
 
19
19
  spec.add_dependency 'erubi', '~> 1.4'
20
- spec.add_dependency 'karafka', '>= 2.0.29', '< 3.0.0'
21
- spec.add_dependency 'karafka-core', '>= 2.0.10', '< 3.0.0'
20
+ spec.add_dependency 'karafka', '>= 2.0.33', '< 3.0.0'
21
+ spec.add_dependency 'karafka-core', '>= 2.0.12', '< 3.0.0'
22
22
  spec.add_dependency 'roda', '~> 3.63'
23
23
  spec.add_dependency 'tilt', '~> 2.0'
24
24
 
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Karafka
4
+ module Web
5
+ # Karafka itself depends on Thor, so we can use it
6
+ class Cli < Thor
7
+ include ::Karafka::Helpers::Colorize
8
+
9
+ # Code that is needed in the `karafka.rb` to connect Web UI to Karafka
10
+ ENABLER_CODE = 'Karafka::Web.enable!'
11
+
12
+ private_constant :ENABLER_CODE
13
+
14
+ package_name 'Karafka Web'
15
+
16
+ desc 'install', 'Installs the Web UI'
17
+ method_option(
18
+ :replication_factor,
19
+ desc: 'Replication factor for created topics',
20
+ default: 1,
21
+ type: :numeric
22
+ )
23
+ # Installs Karafka Web
24
+ def install
25
+ puts
26
+ puts 'Installing Karafka Web UI...'
27
+ puts
28
+ puts 'Creating necessary topics and populating state data...'
29
+
30
+ Karafka::Web::Installer.new.bootstrap!(replication_factor: options[:replication_factor])
31
+
32
+ puts 'Updating the Karafka boot file...'
33
+
34
+ if File.read(Karafka.boot_file).include?(ENABLER_CODE)
35
+ puts "Web UI #{green('already')} installed."
36
+ else
37
+ File.open(Karafka.boot_file, 'a') do |f|
38
+ f << "\n#{ENABLER_CODE}\n"
39
+ end
40
+ end
41
+
42
+ puts
43
+ puts("Installation #{green('completed')}. Have fun!")
44
+ puts
45
+ end
46
+
47
+ desc 'reset', 'Resets the Web UI by removing all the Web topics and creating them again'
48
+ # Resets Karafka Web
49
+ def reset
50
+ puts
51
+ puts 'Resetting Karafka Web UI...'
52
+ Karafka::Web::Installer.new.reset!
53
+ puts
54
+ puts("Resetting #{green('completed')}. Have fun!")
55
+ puts
56
+ end
57
+
58
+ desc 'uninstall', 'Removes all the Web UI topics and the enabled code'
59
+ # Uninstalls Karafka Web
60
+ def uninstall
61
+ puts
62
+ puts 'Uninstalling Karafka Web UI...'
63
+ Karafka::Web::Installer.new.uninstall!
64
+
65
+ puts 'Updating the Karafka boot file...'
66
+
67
+ karafka_rb = File.readlines(Karafka.boot_file)
68
+ if karafka_rb.any? { |line| line.include?(ENABLER_CODE) }
69
+ karafka_rb.delete_if { |line| line.include?(ENABLER_CODE) }
70
+
71
+ File.write(Karafka.boot_file, karafka_rb.join)
72
+ end
73
+
74
+ puts
75
+ puts("Uninstalling #{green('completed')}. Goodbye!")
76
+ puts
77
+ end
78
+ end
79
+ end
80
+ end
@@ -56,6 +56,11 @@ module Karafka
56
56
 
57
57
  # States processing related settings
58
58
  setting :processing do
59
+ # Should we actively process reports
60
+ # This can be disabled in case of using a multi-tenant approach where only one of the
61
+ # apps should materialize the state
62
+ setting :active, default: true
63
+
59
64
  # What should be the consumer group name for web consumer
60
65
  setting :consumer_group, default: 'karafka_web'
61
66
 
@@ -13,6 +13,30 @@ module Karafka
13
13
  bootstrap_state!
14
14
  end
15
15
 
16
+ # Removes all the Karafka topics and creates them again with the same replication factor
17
+ def reset!
18
+ states_topic = ::Karafka::Web.config.topics.consumers.states
19
+ replication_factor = ::Karafka::Admin
20
+ .cluster_info
21
+ .topics
22
+ .find { |topic| topic[:topic_name] == states_topic }
23
+ .fetch(:partitions)
24
+ .first
25
+ .fetch(:replica_count)
26
+
27
+ uninstall!
28
+ bootstrap!(replication_factor: replication_factor)
29
+ end
30
+
31
+ # Removes all the Karafka Web topics
32
+ def uninstall!
33
+ [
34
+ ::Karafka::Web.config.topics.consumers.states,
35
+ ::Karafka::Web.config.topics.consumers.reports,
36
+ ::Karafka::Web.config.topics.errors
37
+ ].each { |topic_name| ::Karafka::Admin.delete_topic(topic_name) }
38
+ end
39
+
16
40
  # Adds the extra needed consumer group, topics and routes for Web UI to be able to operate
17
41
  def enable!
18
42
  ::Karafka::App.routes.draw do
@@ -21,6 +45,7 @@ module Karafka
21
45
  consumer_group ::Karafka::Web.config.processing.consumer_group do
22
46
  # Topic we listen on to materialize the states
23
47
  topic ::Karafka::Web.config.topics.consumers.reports do
48
+ active ::Karafka::Web.config.processing.active
24
49
  # Since we materialize state in intervals, we can poll for half of this time without
25
50
  # impacting the reporting responsiveness
26
51
  max_wait_time ::Karafka::Web.config.processing.interval / 2
@@ -61,38 +86,49 @@ module Karafka
61
86
  #
62
87
  # @param replication_factor [Integer]
63
88
  def bootstrap_topics!(replication_factor = 1)
64
- # This topic needs to have one partition
65
- ::Karafka::Admin.create_topic(
66
- ::Karafka::Web.config.topics.consumers.states,
67
- 1,
68
- replication_factor,
69
- # We care only about the most recent state, previous are irrelevant
70
- { 'cleanup.policy': 'compact' }
71
- )
89
+ existing_topics = ::Karafka::Admin.cluster_info.topics.map { |topic| topic[:topic_name] }
72
90
 
73
- # This topic needs to have one partition
74
- ::Karafka::Admin.create_topic(
75
- ::Karafka::Web.config.topics.consumers.reports,
76
- 1,
77
- replication_factor,
78
- # We do not need to to store this data for longer than 7 days as this data is only used
79
- # to materialize the end states
80
- # On the other hand we do not want to have it really short-living because in case of a
81
- # consumer crash, we may want to use this info to catch up and backfill the state
82
- { 'retention.ms': 7 * 24 * 60 * 60 * 1_000 }
83
- )
91
+ consumers_states_topic = ::Karafka::Web.config.topics.consumers.states
92
+ consumers_reports_topic = ::Karafka::Web.config.topics.consumers.reports
93
+ errors_topic = ::Karafka::Web.config.topics.errors
84
94
 
85
- # All the errors will be dispatched here
86
- # This topic can have multiple partitions but we go with one by default. A single Ruby
87
- # process should not crash that often and if there is an expectation of a higher volume
88
- # of errors, this can be changed by the end user
89
- ::Karafka::Admin.create_topic(
90
- ::Karafka::Web.config.topics.errors,
91
- 1,
92
- replication_factor
93
- )
95
+ # Create only if needed
96
+ unless existing_topics.include?(consumers_states_topic)
97
+ # This topic needs to have one partition
98
+ ::Karafka::Admin.create_topic(
99
+ consumers_states_topic,
100
+ 1,
101
+ replication_factor,
102
+ # We care only about the most recent state, previous are irrelevant
103
+ { 'cleanup.policy': 'compact' }
104
+ )
105
+ end
94
106
 
95
- bootstrap_state!
107
+ unless existing_topics.include?(consumers_reports_topic)
108
+ # This topic needs to have one partition
109
+ ::Karafka::Admin.create_topic(
110
+ consumers_reports_topic,
111
+ 1,
112
+ replication_factor,
113
+ # We do not need to to store this data for longer than 7 days as this data is only used
114
+ # to materialize the end states
115
+ # On the other hand we do not want to have it really short-living because in case of a
116
+ # consumer crash, we may want to use this info to catch up and backfill the state
117
+ { 'retention.ms': 7 * 24 * 60 * 60 * 1_000 }
118
+ )
119
+ end
120
+
121
+ unless existing_topics.include?(errors_topic)
122
+ # All the errors will be dispatched here
123
+ # This topic can have multiple partitions but we go with one by default. A single Ruby
124
+ # process should not crash that often and if there is an expectation of a higher volume
125
+ # of errors, this can be changed by the end user
126
+ ::Karafka::Admin.create_topic(
127
+ errors_topic,
128
+ 1,
129
+ replication_factor
130
+ )
131
+ end
96
132
  end
97
133
 
98
134
  # Creates the initial state record with all values being empty
@@ -57,7 +57,8 @@ module Karafka
57
57
  topic: Karafka::Web.config.topics.consumers.states,
58
58
  payload: @consumers_aggregator.to_json,
59
59
  # This will ensure that the consumer states are compacted
60
- key: Karafka::Web.config.topics.consumers.states
60
+ key: Karafka::Web.config.topics.consumers.states,
61
+ partition: 0
61
62
  )
62
63
  end
63
64
  end
@@ -18,6 +18,7 @@ module Karafka
18
18
  required(:last_offset) { |val| val.is_a?(Integer) && val >= 0 }
19
19
  required(:comitted_offset) { |val| val.is_a?(Integer) }
20
20
  required(:type) { |val| %w[consume revoked shutdown].include?(val) }
21
+ required(:tags) { |val| val.is_a?(Karafka::Core::Taggable::Tags) }
21
22
  end
22
23
  end
23
24
  end
@@ -27,6 +27,7 @@ module Karafka
27
27
  required(:status) { |val| ::Karafka::Status::STATES.key?(val.to_sym) }
28
28
  required(:listeners) { |val| val.is_a?(Integer) && val >= 0 }
29
29
  required(:concurrency) { |val| val.is_a?(Integer) && val.positive? }
30
+ required(:tags) { |val| val.is_a?(Karafka::Core::Taggable::Tags) }
30
31
 
31
32
  required(:cpu_usage) do |val|
32
33
  val.is_a?(Array) &&
@@ -74,7 +74,7 @@ module Karafka
74
74
  # @param error [StandardError] error that occurred
75
75
  # @return [Array<String, String, String>] array with error name, message and backtrace
76
76
  def extract_error_info(error)
77
- error_message = error.message.to_s
77
+ error_message = error.message.to_s.dup
78
78
  error_message.force_encoding('utf-8')
79
79
  error_message.scrub!
80
80
 
@@ -146,7 +146,8 @@ module Karafka
146
146
  comitted_offset: consumer.coordinator.seek_offset - 1,
147
147
  consumer: consumer.class.to_s,
148
148
  consumer_group: consumer.topic.consumer_group.id,
149
- type: type
149
+ type: type,
150
+ tags: consumer.tags
150
151
  }
151
152
  end
152
153
  end
@@ -11,13 +11,18 @@ module Karafka
11
11
 
12
12
  attr_reader :counters, :consumer_groups, :errors, :times, :pauses, :jobs
13
13
 
14
+ # Current schema version
15
+ # This can be used in the future for detecting incompatible changes and writing
16
+ # migrations
17
+ SCHEMA_VERSION = '1.0.1'
18
+
14
19
  # 60 seconds window for time tracked window-based metrics
15
20
  TIMES_TTL = 60
16
21
 
17
22
  # Times ttl in ms
18
23
  TIMES_TTL_MS = TIMES_TTL * 1_000
19
24
 
20
- private_constant :TIMES_TTL, :TIMES_TTL_MS
25
+ private_constant :TIMES_TTL, :TIMES_TTL_MS, :SCHEMA_VERSION
21
26
 
22
27
  def initialize
23
28
  @counters = {
@@ -47,7 +52,7 @@ module Karafka
47
52
  # @return [Hash] report hash with all the details about consumer operations
48
53
  def to_report
49
54
  {
50
- schema_version: '1.0.0',
55
+ schema_version: SCHEMA_VERSION,
51
56
  type: 'consumer',
52
57
  dispatched_at: float_now,
53
58
 
@@ -61,7 +66,8 @@ module Karafka
61
66
  memory_total_usage: memory_total_usage,
62
67
  memory_size: memory_size,
63
68
  cpu_count: cpu_count,
64
- cpu_usage: cpu_usage
69
+ cpu_usage: cpu_usage,
70
+ tags: Karafka::Process.tags
65
71
  },
66
72
 
67
73
  versions: {
@@ -49,7 +49,8 @@ module Karafka
49
49
  {
50
50
  topic: ::Karafka::Web.config.topics.consumers.reports,
51
51
  payload: consumer_report.to_json,
52
- key: consumer_report[:process][:name]
52
+ key: consumer_report[:process][:name],
53
+ partition: 0
53
54
  }
54
55
  ]
55
56
 
@@ -71,6 +71,11 @@ module Karafka
71
71
  render_response controller.index
72
72
  end
73
73
  end
74
+
75
+ r.get 'status' do
76
+ controller = Controllers::Status.new(params)
77
+ render_response controller.show
78
+ end
74
79
  end
75
80
  end
76
81
  end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Karafka
4
+ module Web
5
+ module Ui
6
+ module Controllers
7
+ # View that helps understand the status of the Web UI
8
+ # Many people reported problems understanding the requirements or misconfigured things.
9
+ # While all of the things are documented, people are lazy. Hence we provide a status
10
+ # page where we check that everything is as expected and if not, we can provide some
11
+ # helpful instructions on how to fix the issues.
12
+ class Status < Base
13
+ # Displays the Web UI setup status
14
+ def show
15
+ @status = Models::Status.new
16
+
17
+ respond
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -40,6 +40,13 @@ module Karafka
40
40
  .sort_by(&:started_at)
41
41
  end
42
42
 
43
+ # @return [Array<String>] tags of this consuming process
44
+ # @note We use direct reference here and a fallback for users that come from the versions
45
+ # that did not report tags
46
+ def tags
47
+ @hash[:process][:tags] || []
48
+ end
49
+
43
50
  # @return [Integer] collective lag on this process
44
51
  def lag_stored
45
52
  consumer_groups