sbmt-outbox 6.3.1 → 6.4.1

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: 952db6c0164054fe8a19297680900749dacf124e2987d2a49a02304f4a02f0db
4
- data.tar.gz: b765f1c66e936431070f61e946ac9a50b7b2b2966af01f124923c8cb5f70cdab
3
+ metadata.gz: 6f4bad1209d38b5bc078043b5f70ebb021709b6fb6ec46ea21f07469e361c96c
4
+ data.tar.gz: 239b12886db166a8e1eecc77418c18a3da324220877ebec1a26071916675630a
5
5
  SHA512:
6
- metadata.gz: 2c6e1a536dc8ece25ceb807db39e1f4f52fa70f79d6eadfd834707da8d7f4593575cc0563e638133f973fa4205c8e9fe14f1e28ffbbe44bf1f5f35ec1748fb9a
7
- data.tar.gz: f5b8196a367b1c38ed65fdaa95cecdd7dd245524c17e317088f73387ea114262d81ed1062b4f1486cf084f55e0a31b64b08999a0d42b30117e41c841bbb15012
6
+ metadata.gz: b279fdac2c90a1e52c93c6f6bf500dea62329b3fd1c3fa7de348a7931ac92c653addb462cf7e66521f4566017a13aaaa0e0541ebc0b9c144868caf3904f1c4f4
7
+ data.tar.gz: 852f86d9894830a4e4e5ac9943647b05769ded665abfb65590470f9f3114b2acb86fe52cf58adaf74ce34cf9caf529765f10675eda9c02e07e1be709a754d826
data/README.md CHANGED
@@ -224,7 +224,11 @@ The `outbox.yml` configuration file is the main configuration for the gem, where
224
224
  default: &default
225
225
  owner: foo-team # optional, used in Yabeda metrics
226
226
  bucket_size: 16 # optional, default 16, see into about the buckets at the #Concurrency section
227
+ metrics:
228
+ enabled: true # default false, yabeda server autostart with port: 9090 and path: /metrics
229
+ port: 9090 # optional, default, used in Yabeda metrics
227
230
  probes:
231
+ enabled: false # optional, default true
228
232
  port: 5555 # default, used for Kubernetes probes
229
233
 
230
234
  outbox_items: # outbox items section
@@ -1,6 +1,8 @@
1
1
  default: &default
2
2
  owner: owner-team
3
3
  bucket_size: 16
4
+ metrics:
5
+ enabled: true
4
6
 
5
7
  probes:
6
8
  port: SET-UP-YOUR-HEALTHCHECK-PORT-HERE
@@ -69,8 +69,8 @@ module Sbmt
69
69
  $stdout.puts AsciiArt.logo
70
70
  $stdout.puts "Outbox/Inbox worker has been started"
71
71
  $stdout.puts "Version: #{VERSION}"
72
- $stdout.puts "Starting probes..."
73
72
  Sbmt::Outbox::Probes::Probe.run_probes
73
+ Sbmt::Outbox::Probes::Metrics.run_metrics
74
74
 
75
75
  worker.start
76
76
  end
@@ -137,6 +137,13 @@ module Sbmt
137
137
  $stdout.puts "Going to shut down..."
138
138
  worker.stop
139
139
  end
140
+
141
+ # normal kill with number 3
142
+ Signal.trap("SIGQUIT") do
143
+ $stdout.puts AsciiArt.shutdown
144
+ $stdout.puts "Going to shut down..."
145
+ worker.stop
146
+ end
140
147
  end
141
148
  end
142
149
  end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sbmt
4
+ module Outbox
5
+ module Probes
6
+ class Metrics
7
+ DEFAULT_YABEDA_PORT = 9090
8
+ DEFAULT_YABEDA_PATH = "/metrics"
9
+ class << self
10
+ def run_metrics
11
+ return unless autostart_yabeda_server?
12
+
13
+ if defined?(Yabeda)
14
+ $stdout.puts "Starting metrics http-server..."
15
+
16
+ start_webrick(
17
+ Yabeda::Prometheus::Mmap::Exporter::NOT_FOUND_HANDLER,
18
+ middlewares: {::Yabeda::Prometheus::Exporter => {path: DEFAULT_YABEDA_PATH}},
19
+ port: yabeda_port
20
+ )
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def yabeda_port
27
+ Sbmt::Outbox.yaml_config.dig(:metrics, :port) || DEFAULT_YABEDA_PORT
28
+ end
29
+
30
+ def start_webrick(app, middlewares:, port:)
31
+ Thread.new do
32
+ ::Rack::Handler::WEBrick.run(
33
+ ::Rack::Builder.new do
34
+ middlewares.each do |middleware, options|
35
+ use middleware, **options
36
+ end
37
+ run app
38
+ end,
39
+ Host: "0.0.0.0",
40
+ Port: port
41
+ )
42
+ end
43
+ end
44
+
45
+ def autostart_yabeda_server?
46
+ Sbmt::Outbox.yaml_config.dig(:metrics, :enabled) || false
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -7,6 +7,10 @@ module Sbmt
7
7
  DEFAULT_PROBE_PORT = 5555
8
8
  class << self
9
9
  def run_probes
10
+ return unless autostart_probe?
11
+
12
+ $stdout.puts "Starting probes..."
13
+
10
14
  ::HttpHealthCheck.run_server_async(
11
15
  port: probe_port,
12
16
  rack_app: HttpHealthCheck::RackApp.configure do |c|
@@ -31,6 +35,12 @@ module Sbmt
31
35
 
32
36
  Sbmt::Outbox.yaml_config.fetch(:probes).fetch(:port)
33
37
  end
38
+
39
+ def autostart_probe?
40
+ value = Sbmt::Outbox.yaml_config.dig(:probes, :enabled)
41
+ value = true if value.nil?
42
+ value
43
+ end
34
44
  end
35
45
  end
36
46
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sbmt
4
4
  module Outbox
5
- VERSION = "6.3.1"
5
+ VERSION = "6.4.1"
6
6
  end
7
7
  end
data/lib/sbmt/outbox.rb CHANGED
@@ -38,6 +38,7 @@ require_relative "outbox/engine"
38
38
  require_relative "outbox/middleware/builder"
39
39
  require_relative "outbox/middleware/runner"
40
40
  require_relative "outbox/probes/probe"
41
+ require_relative "outbox/probes/metrics"
41
42
  require_relative "outbox/redis_client_factory"
42
43
 
43
44
  module Sbmt
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sbmt-outbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.3.1
4
+ version: 6.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sbermarket Ruby-Platform Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-02 00:00:00.000000000 Z
11
+ date: 2024-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool
@@ -586,6 +586,7 @@ files:
586
586
  - lib/sbmt/outbox/middleware/sentry/tracing_batch_process_middleware.rb
587
587
  - lib/sbmt/outbox/middleware/sentry/tracing_item_process_middleware.rb
588
588
  - lib/sbmt/outbox/middleware/sentry/transaction.rb
589
+ - lib/sbmt/outbox/probes/metrics.rb
589
590
  - lib/sbmt/outbox/probes/probe.rb
590
591
  - lib/sbmt/outbox/redis_client_factory.rb
591
592
  - lib/sbmt/outbox/tasks/delete_failed_items.rake