Skip to content

Commit 7645000

Browse files
authored
Merge pull request #371 from appsignal/jobs-http-test-setups
Test new enqueue and HTTP client Ruby instrumentations
2 parents 96d7707 + 1d3ec71 commit 7645000

275 files changed

Lines changed: 7132 additions & 2 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ jobs:
286286
- ruby/rails7-sequel
287287
- ruby/rails7-sidekiq
288288
- ruby/rails8-delayed-job
289+
- ruby/rails8-que
290+
- ruby/rails8-resque
289291
- ruby/rails8-sidekiq
290292
- ruby/rails8-sidekiq-opentelemetry
291293
- ruby/sinatra-redis

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ rake app=ruby/rails7-sidekiq app:up
129129
rake app=ruby/rails7-solid-cache app:up
130130
rake app=ruby/rails7-solid-queue app:up
131131
rake app=ruby/rails8-delayed-job app:up
132+
rake app=ruby/rails8-que app:up
133+
rake app=ruby/rails8-resque app:up
132134
rake app=ruby/rails8-sidekiq app:up
133135
rake app=ruby/rails8-sidekiq-opentelemetry app:up
134136
rake app=ruby/shoryuken app:up
@@ -221,6 +223,8 @@ rake app=ruby/rails7-sequel app:bot
221223
rake app=ruby/rails7-sidekiq app:bot
222224
rake app=ruby/rails7-solid-cache app:bot
223225
rake app=ruby/rails7-solid-queue app:bot
226+
rake app=ruby/rails8-que app:bot
227+
rake app=ruby/rails8-resque app:bot
224228
rake app=ruby/rails8-sidekiq app:bot
225229
rake app=ruby/rails8-sidekiq-opentelemetry app:bot
226230
rake app=ruby/sinatra-alpine app:bot
@@ -265,6 +269,8 @@ rake app=ruby/rails7-sequel mode=collector app:up
265269
rake app=ruby/rails7-solid-cache mode=collector app:up
266270
rake app=ruby/rails7-solid-queue mode=collector app:up
267271
rake app=ruby/rails8-delayed-job mode=collector app:up
272+
rake app=ruby/rails8-que mode=collector app:up
273+
rake app=ruby/rails8-resque mode=collector app:up
268274
rake app=ruby/rails8-sidekiq mode=collector app:up
269275
rake app=ruby/sinatra-alpine mode=collector app:up
270276
rake app=ruby/sinatra-gvltools mode=collector app:up
@@ -360,6 +366,8 @@ rake app=ruby/rails7-sidekiq app:restart
360366
rake app=ruby/rails7-solid-cache app:restart
361367
rake app=ruby/rails7-solid-queue app:restart
362368
rake app=ruby/rails8-delayed-job app:restart
369+
rake app=ruby/rails8-que app:restart
370+
rake app=ruby/rails8-resque app:restart
363371
rake app=ruby/rails8-sidekiq app:restart
364372
rake app=ruby/rails8-sidekiq-opentelemetry app:restart
365373
rake app=ruby/shoryuken app:restart
@@ -462,6 +470,8 @@ rake app=ruby/rails7-sidekiq app:bash
462470
rake app=ruby/rails7-solid-cache app:bash
463471
rake app=ruby/rails7-solid-queue app:bash
464472
rake app=ruby/rails8-delayed-job app:bash
473+
rake app=ruby/rails8-que app:bash
474+
rake app=ruby/rails8-resque app:bash
465475
rake app=ruby/rails8-sidekiq app:bash
466476
rake app=ruby/rails8-sidekiq-opentelemetry app:bash
467477
rake app=ruby/shoryuken app:bash
@@ -564,6 +574,8 @@ rake app=ruby/rails7-sidekiq app:console
564574
rake app=ruby/rails7-solid-cache app:console
565575
rake app=ruby/rails7-solid-queue app:console
566576
rake app=ruby/rails8-delayed-job app:console
577+
rake app=ruby/rails8-que app:console
578+
rake app=ruby/rails8-resque app:console
567579
rake app=ruby/rails8-sidekiq app:console
568580
rake app=ruby/rails8-sidekiq-opentelemetry app:console
569581
rake app=ruby/shoryuken app:console
@@ -666,6 +678,8 @@ rake app=ruby/rails7-sidekiq app:diagnose
666678
rake app=ruby/rails7-solid-cache app:diagnose
667679
rake app=ruby/rails7-solid-queue app:diagnose
668680
rake app=ruby/rails8-delayed-job app:diagnose
681+
rake app=ruby/rails8-que app:diagnose
682+
rake app=ruby/rails8-resque app:diagnose
669683
rake app=ruby/rails8-sidekiq app:diagnose
670684
rake app=ruby/rails8-sidekiq-opentelemetry app:diagnose
671685
rake app=ruby/shoryuken app:diagnose
@@ -768,6 +782,8 @@ rake app=ruby/rails7-sidekiq app:tail:appsignal
768782
rake app=ruby/rails7-solid-cache app:tail:appsignal
769783
rake app=ruby/rails7-solid-queue app:tail:appsignal
770784
rake app=ruby/rails8-delayed-job app:tail:appsignal
785+
rake app=ruby/rails8-que app:tail:appsignal
786+
rake app=ruby/rails8-resque app:tail:appsignal
771787
rake app=ruby/rails8-sidekiq app:tail:appsignal
772788
rake app=ruby/rails8-sidekiq-opentelemetry app:tail:appsignal
773789
rake app=ruby/shoryuken app:tail:appsignal

ruby/rails6-shoryuken/app/app/controllers/tests_controller.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,9 @@ def active_job_error_job
1616
ErrorJob.perform_later("ActiveJob ErrorJob queued")
1717
render :html => "ActiveJob ErrorJob queued, refresh to queue a new one!"
1818
end
19+
20+
def shoryuken_native_job
21+
NativeWorker.perform_async(:body => "Native Shoryuken job queued")
22+
render :html => "Native Shoryuken job queued, refresh to queue a new one!"
23+
end
1924
end

ruby/rails6-shoryuken/app/app/views/tests/index.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
<li><%= link_to "Slow request", slow_path %></li>
66
<li><%= link_to "ActiveJob ErrorJob", active_job_error_job_path %></li>
77
<li><%= link_to "ActiveJob PerformanceJob", active_job_performance_job_path %></li>
8+
<li><%= link_to "Native Shoryuken worker", shoryuken_native_job_path %></li>
89
</ul>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# A native Shoryuken worker (as opposed to the Active Job jobs in app/jobs).
2+
# Enqueuing it with `NativeWorker.perform_async` from a web request records an
3+
# `enqueue.shoryuken` event on that request's transaction, through Shoryuken's
4+
# client middleware. It uses its own queue so it doesn't clash with the Active
5+
# Job adapter, which owns the "default" queue.
6+
class NativeWorker
7+
include Shoryuken::Worker
8+
9+
shoryuken_options :queue => "native", :auto_delete => true, :body_parser => :json
10+
11+
def perform(_sqs_msg, body)
12+
puts "Performing NativeWorker job: #{body}"
13+
end
14+
end

ruby/rails6-shoryuken/app/config/initializers/shoryuken.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,10 @@
1717
verify_checksums: false # Disable for mock server
1818
)
1919
end
20+
21+
# Load the native worker on boot so it registers for its queue. In development
22+
# classes load lazily, so without this the Shoryuken server wouldn't know to
23+
# route the "native" queue to NativeWorker.
24+
Rails.application.config.to_prepare do
25+
NativeWorker
26+
end

ruby/rails6-shoryuken/app/config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
get "/error", to: "tests#error"
44
get "/active_job_performance_job", to: "tests#active_job_performance_job"
55
get "/active_job_error_job", to: "tests#active_job_error_job"
6+
get "/shoryuken_native_job", to: "tests#shoryuken_native_job"
67
root :to => "tests#index"
78
end

ruby/rails6-shoryuken/app/processmon.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ args = [
1111
"exec",
1212
"shoryuken",
1313
"-q=default",
14+
"-q=native",
1415
"-R"
1516
]
1617
working_dir = "/app"

ruby/rails6-shoryuken/commands/run

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ bin/rails db:migrate
2222

2323
echo "Create sqs queues in mock server"
2424
bundle exec shoryuken sqs create default
25+
bundle exec shoryuken sqs create native
2526

2627
/commands/processmon processmon.toml

ruby/rails7-sidekiq/app/Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ gem "sidekiq", "~> 7.1.6"
1212
gem "appsignal", :path => "/integration"
1313
gem "excon"
1414
gem "http"
15+
gem "faraday"
1516

1617
# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
1718
gem "sprockets-rails"

0 commit comments

Comments
 (0)