yabeda-rack-queue 0.2.0 → 0.2.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 +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +2 -2
- data/lib/yabeda/rack/queue/metric.rb +4 -0
- data/lib/yabeda/rack/queue/middleware.rb +2 -0
- data/lib/yabeda/rack/queue/version.rb +1 -1
- data/test/yabeda/rack/queue/middleware_test.rb +21 -0
- data/test/yabeda/rack/queue/railtie_test.rb +35 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a2460b8b476ceba45cccd0edd32320f133780bc01681d08bcf5fb162b7dd0cf4
|
|
4
|
+
data.tar.gz: 3b69c898a813804c2f8194fa9e5a84cf1508c1d3df2eb52096683e1b4612d09d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7b34b7083e9afb7c53825d8fd2645d74d36f4b6e9551885546de59f19d836199eb9cf3abc2a4a504d9844a52b468d157c1e6c1a3b7c1df62436b2286b1199271
|
|
7
|
+
data.tar.gz: c82d59eb210d12595a0c53a4330d004d0d7d4667fdb71101d0b2c2e4a017bc78b77f91ed312ceb6fae8bc68d2d28fb3ee6c7c761eb5020ffbedfc937af6b9788
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.1 - 2026-06-29
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- Keep requests flowing if rack queue metric reporting fails, logging the error instead.
|
|
8
|
+
- Load `yabeda/railtie` when Rails appears after Yabeda was already required.
|
|
9
|
+
|
|
3
10
|
## 0.2.0 - 2026-03-09
|
|
4
11
|
|
|
5
12
|
### Changed
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
yabeda-rack-queue (0.2.
|
|
4
|
+
yabeda-rack-queue (0.2.1)
|
|
5
5
|
yabeda (>= 0.14, < 1.0)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
@@ -114,7 +114,7 @@ CHECKSUMS
|
|
|
114
114
|
unicode-display_width (3.2.0) sha256=0cdd96b5681a5949cdbc2c55e7b420facae74c4aaf9a9815eee1087cb1853c42
|
|
115
115
|
unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f
|
|
116
116
|
yabeda (0.14.0) sha256=bc517bf22d692ebd80a29fc9fd2246c257aaf92d10b2735a775e2419351a43bf
|
|
117
|
-
yabeda-rack-queue (0.2.
|
|
117
|
+
yabeda-rack-queue (0.2.1)
|
|
118
118
|
|
|
119
119
|
BUNDLED WITH
|
|
120
120
|
4.0.3
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
require "yabeda"
|
|
4
4
|
|
|
5
|
+
# Yabeda only loads its Railtie if Rails exists when Yabeda is first required.
|
|
6
|
+
# Puma plugins can require Yabeda before Rails, so retry when this gem loads.
|
|
7
|
+
require "yabeda/railtie" if defined?(::Rails::Railtie)
|
|
8
|
+
|
|
5
9
|
Yabeda.configure do
|
|
6
10
|
group :rack_queue do
|
|
7
11
|
histogram :duration,
|
|
@@ -32,6 +32,8 @@ module Yabeda
|
|
|
32
32
|
start = @parser.parse(env["HTTP_X_REQUEST_START"], now: now) ||
|
|
33
33
|
@parser.parse(env["HTTP_X_QUEUE_START"], now: now)
|
|
34
34
|
report_queue_time(env, now, start) if start
|
|
35
|
+
rescue => error
|
|
36
|
+
@logger.warn("rack queue metric failed: #{error.class}: #{error.message}")
|
|
35
37
|
end
|
|
36
38
|
|
|
37
39
|
def report_queue_time(env, now, request_start)
|
|
@@ -14,6 +14,12 @@ class CapturingReporter
|
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
class FailingReporter
|
|
18
|
+
def observe(_value)
|
|
19
|
+
raise NoMethodError, "undefined method `rack_queue' for Yabeda:Module"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
17
23
|
class CapturingLogger
|
|
18
24
|
attr_reader :warnings
|
|
19
25
|
|
|
@@ -144,6 +150,21 @@ class MiddlewareTest < Minitest::Test
|
|
|
144
150
|
assert_empty @reporter.values
|
|
145
151
|
end
|
|
146
152
|
|
|
153
|
+
def test_metric_reporting_errors_are_logged_and_do_not_break_request
|
|
154
|
+
middleware = Yabeda::Rack::Queue::Middleware.new(
|
|
155
|
+
@app,
|
|
156
|
+
reporter: FailingReporter.new,
|
|
157
|
+
clock: @clock,
|
|
158
|
+
logger: @logger
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
result = middleware.call("HTTP_X_REQUEST_START" => "t=1699999999.9")
|
|
162
|
+
|
|
163
|
+
assert_same @response, result
|
|
164
|
+
assert_equal 1, @app.called_count
|
|
165
|
+
assert_includes @logger.warnings.join("\n"), "rack queue metric failed: NoMethodError"
|
|
166
|
+
end
|
|
167
|
+
|
|
147
168
|
def test_drops_negative_queue_times_and_logs_warning
|
|
148
169
|
@middleware.call("HTTP_X_REQUEST_START" => "t=1700000000.1")
|
|
149
170
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "test_helper"
|
|
4
|
+
require "open3"
|
|
5
|
+
require "rbconfig"
|
|
6
|
+
|
|
7
|
+
class RailtieTest < Minitest::Test
|
|
8
|
+
def test_loads_yabeda_railtie_when_rails_appears_after_yabeda
|
|
9
|
+
script = <<~RUBY
|
|
10
|
+
require "bundler/setup"
|
|
11
|
+
require "yabeda"
|
|
12
|
+
|
|
13
|
+
module Rails
|
|
14
|
+
class Railtie
|
|
15
|
+
def self.config
|
|
16
|
+
@config ||= Config.new
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class Config
|
|
20
|
+
def after_initialize
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
require "yabeda/rack/queue"
|
|
27
|
+
|
|
28
|
+
abort "Yabeda::Rails::Railtie was not loaded" unless defined?(Yabeda::Rails::Railtie)
|
|
29
|
+
RUBY
|
|
30
|
+
|
|
31
|
+
stdout, stderr, status = Open3.capture3("bundle", "exec", RbConfig.ruby, "-Ilib", "-e", script)
|
|
32
|
+
|
|
33
|
+
assert status.success?, [stdout, stderr].join("\n")
|
|
34
|
+
end
|
|
35
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: yabeda-rack-queue
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nate Berkopec
|
|
@@ -167,6 +167,7 @@ files:
|
|
|
167
167
|
- test/yabeda/rack/queue/metric_test.rb
|
|
168
168
|
- test/yabeda/rack/queue/middleware_performance_test.rb
|
|
169
169
|
- test/yabeda/rack/queue/middleware_test.rb
|
|
170
|
+
- test/yabeda/rack/queue/railtie_test.rb
|
|
170
171
|
- yabeda-rack-queue.gemspec
|
|
171
172
|
homepage: https://github.com/speedshop/yabeda-rack-queue
|
|
172
173
|
licenses:
|
|
@@ -191,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
191
192
|
- !ruby/object:Gem::Version
|
|
192
193
|
version: '0'
|
|
193
194
|
requirements: []
|
|
194
|
-
rubygems_version: 4.0.
|
|
195
|
+
rubygems_version: 4.0.10
|
|
195
196
|
specification_version: 4
|
|
196
197
|
summary: Yabeda middleware for HTTP request queue duration
|
|
197
198
|
test_files: []
|