rails_pod_kit 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0dda5e5202f1bb5e509fad032de8449c5d8e9eec78c0cedcd0a59d20cc4f0d32
4
- data.tar.gz: ebccb551ba5dcfd23c1dc2e668d417f59fb1d76f06522e02c352cea1f5e0dca5
3
+ metadata.gz: a40b144ace0af8e73c9a44f21ebb7111e726543a343be3c8f8969ee7befb166c
4
+ data.tar.gz: 5ec92a058a63671e877011591d2a5585a98a9da5c851db86ea5924814cbed32a
5
5
  SHA512:
6
- metadata.gz: f6ab1b5432bf79341efabb50d0d3d1862dafa49523bbbc8f70ea718eb520d258b7c216da274f0d184dbeb1737c887ebfb19f04fbcc656e8fd39c6a0e057d6346
7
- data.tar.gz: c2e8aa9a3b35a1ea4d557a47be04810c69e79de50a0297593388f90c1be48f8a144a281ad3d26a6c42c4564ba608d6ded064ba53b12f5f49279ddefa940e049c
6
+ metadata.gz: fca2fbe470f2eaa9c8039034d8795ca9006ea10e835d8db907c20aa3a1740eeffa2bc94a2d31bc024130028f15e4340e4c59dcc3fc330cbb34d12b649bd1f4b1
7
+ data.tar.gz: 04e115d689e42b62975846ca67a5312ba7de26fbec65ca970864dbc844131dda53188839ff05f1a81601aeaa652bd42e1f17682d8d22cc08203322b5072bf1b7
data/README.md CHANGED
@@ -611,7 +611,7 @@ serves `solid_queue_*` and nothing else, so the check config needs no filters.
611
611
  localhost-only socket (`no_token: true`, never network-exposed).
612
612
  - **Rack version.** Under **Rack 3+** the mmap exporter's WEBrick handler also
613
613
  needs the `rackup` gem. Under Rack 2.x `webrick` alone is enough, but on
614
- Ruby ≥ 3.5 make sure `ostruct` is in the bundle (Rack 2.2 requires it
614
+ Ruby ≥ 4.0 make sure `ostruct` is in the bundle (Rack 2.2 requires it
615
615
  without declaring it, and it's no longer a default gem).
616
616
  - **Two kinds of entry point.** The main file (`require 'rails_pod_kit'`,
617
617
  what Bundler.require loads in a Rails app) pulls in every integration
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -43,10 +43,16 @@ module RailsPodKit
43
43
  puma_config.plugin :yabeda
44
44
  puma_config.plugin :yabeda_prometheus
45
45
 
46
- # Silence the exporter's per-scrape access log. The `prometheus_silence_logger`
47
- # DSL method is defined by the :yabeda_prometheus plugin, so this must run
48
- # after the plugin is loaded above. See Config#silence_exporter_access_log.
49
- puma_config.prometheus_silence_logger(true) if RailsPodKit.config.silence_exporter_access_log
46
+ # Drop the exporter's per-scrape access log the same way the WEBrick path
47
+ # does (see RailsPodKit::Exporter.start!): the log line comes from the
48
+ # Rack::CommonLogger the exporter's rack app mounts unless this is exactly
49
+ # 'false'. See Config#silence_exporter_access_log.
50
+ #
51
+ # Deliberately not `prometheus_silence_logger(true)`, which is the plugin's
52
+ # own knob: it swaps Puma's whole log writer for LogWriter.null, and that
53
+ # writer also carries the exporter's errors — so a /metrics that raises on
54
+ # every scrape would fail completely silently.
55
+ ENV['PROMETHEUS_EXPORTER_LOG_REQUESTS'] = 'false' if RailsPodKit.config.silence_exporter_access_log
50
56
 
51
57
  # `config/puma.rb` is evaluated before Rails is loaded, so requiring this
52
58
  # gem here loads yabeda *before* `defined?(Rails)`, and yabeda's Railtie
@@ -21,6 +21,8 @@ module RailsPodKit
21
21
  def install!(sidekiq_config = nil)
22
22
  return unless RailsPodKit.enabled?
23
23
 
24
+ export_policy_env!(collect_cluster_metrics: RailsPodKit.config.sidekiq_global_metrics == :all)
25
+
24
26
  require 'yabeda/sidekiq'
25
27
  require 'yabeda/prometheus/mmap'
26
28
 
@@ -72,9 +74,10 @@ module RailsPodKit
72
74
  # server — i.e. the web (Puma) process under the :web policy. The web has the
73
75
  # Sidekiq client configured (Redis access), so yabeda-sidekiq can read the
74
76
  # cluster stats there. We force `collect_cluster_metrics` on and keep
75
- # `declare_process_metrics` off (the web runs no jobs). Must run before
76
- # Yabeda.configure! so the gauges are declared.
77
+ # `declare_process_metrics` off (the web runs no jobs).
77
78
  def enable_global_collection!
79
+ export_policy_env!(collect_cluster_metrics: true, declare_process_metrics: false)
80
+
78
81
  require 'yabeda/sidekiq'
79
82
 
80
83
  Yabeda::Sidekiq.config.collect_cluster_metrics = true
@@ -82,6 +85,24 @@ module RailsPodKit
82
85
  apply_retries_segmentation!
83
86
  end
84
87
 
88
+ # Publishes the policy through yabeda-sidekiq's own env-backed config, and it
89
+ # has to happen *before* `require 'yabeda/sidekiq'`.
90
+ #
91
+ # yabeda-sidekiq declares its cluster gauges inside its own `Yabeda.configure`
92
+ # block, guarded by `collect_cluster_metrics` — and when Yabeda has already
93
+ # been configured (any host where its Railtie ran first) requiring the file
94
+ # evaluates that block immediately. Assigning the flag afterwards is then too
95
+ # late: the gauges are never declared, while the `collect` block — which reads
96
+ # the same flag on every scrape — starts referencing them, and /metrics 500s
97
+ # with a NameError. The env values are read when the config object is built,
98
+ # so setting them here makes the declaration see the policy whenever the
99
+ # require lands.
100
+ def export_policy_env!(collect_cluster_metrics:, declare_process_metrics: nil)
101
+ ENV['YABEDA_SIDEKIQ_COLLECT_CLUSTER_METRICS'] = collect_cluster_metrics.to_s
102
+ ENV['YABEDA_SIDEKIQ_DECLARE_PROCESS_METRICS'] = declare_process_metrics.to_s unless declare_process_metrics.nil?
103
+ ENV['YABEDA_SIDEKIQ_RETRIES_SEGMENTED_BY_QUEUE'] = RailsPodKit.config.retries_segmented_by_queue.to_s
104
+ end
105
+
85
106
  # Starts the background WEBrick exporter shared with the other non-Puma
86
107
  # entry points; guarded there so a re-entrant Sidekiq boot can't double-bind
87
108
  # the port.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_pod_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabio Napoleoni