Skip to content

Commit

Permalink
Support Que 2 keyword arguments (#1281)
Browse files Browse the repository at this point in the history
Report Que 2 keyword arguments as parameters. Que 2 added support for
keyword arguments for jobs or changed how they work.

Closes #883
  • Loading branch information
tombruijn authored Sep 3, 2024
1 parent c48be2c commit 770bdc0
Show file tree
Hide file tree
Showing 9 changed files with 238 additions and 45 deletions.
6 changes: 6 additions & 0 deletions .changesets/add-support-for-que-2-keyword-arguments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
bump: patch
type: add
---

Add support for Que 2 keyword arguments. Que job arguments will now be reported as the `arguments` key for positional arguments and `keyword_arguments` for Ruby keyword arguments.
167 changes: 151 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This is a generated file by the `rake build_matrix:github:generate` task.
# See `build_matrix.yml` for the build matrix.
# Generate this file with `rake build_matrix:github:generate`.
# Generated job count: 117
# Generated job count: 122
---
name: Ruby gem CI
'on':
Expand Down Expand Up @@ -372,8 +372,8 @@ jobs:
JRUBY_OPTS: ''
COV: '1'
BUNDLE_GEMFILE: gemfiles/psych-4.gemfile
ruby_3-3-4__que_ubuntu-latest:
name: Ruby 3.3.4 - que
ruby_3-3-4__que-1_ubuntu-latest:
name: Ruby 3.3.4 - que-1
needs: ruby_3-3-4_ubuntu-latest
runs-on: ubuntu-latest
steps:
Expand All @@ -398,7 +398,34 @@ jobs:
RAILS_ENV: test
JRUBY_OPTS: ''
COV: '1'
BUNDLE_GEMFILE: gemfiles/que.gemfile
BUNDLE_GEMFILE: gemfiles/que-1.gemfile
ruby_3-3-4__que-2_ubuntu-latest:
name: Ruby 3.3.4 - que-2
needs: ruby_3-3-4_ubuntu-latest
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.4
bundler-cache: true
- name: Install gem extension
run: "./support/bundler_wrapper exec rake extension:install"
- name: Print extension install report
run: "[ -e ext/install.report ] && cat ext/install.report || echo 'No ext/install.report
file found'"
- name: Print Makefile log file
run: "[ -f ext/mkmf.log ] && cat ext/mkmf.log || echo 'No ext/mkmf.log file
found'"
- name: Run tests
run: "./support/bundler_wrapper exec rake test"
env:
RAILS_ENV: test
JRUBY_OPTS: ''
COV: '1'
BUNDLE_GEMFILE: gemfiles/que-2.gemfile
ruby_3-3-4__rails-6-1_ubuntu-latest:
name: Ruby 3.3.4 - rails-6.1
needs: ruby_3-3-4_ubuntu-latest
Expand Down Expand Up @@ -970,8 +997,35 @@ jobs:
JRUBY_OPTS: ''
COV: '1'
BUNDLE_GEMFILE: gemfiles/psych-4.gemfile
ruby_3-2-5__que_ubuntu-latest:
name: Ruby 3.2.5 - que
ruby_3-2-5__que-1_ubuntu-latest:
name: Ruby 3.2.5 - que-1
needs: ruby_3-2-5_ubuntu-latest
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.5
bundler-cache: true
- name: Install gem extension
run: "./support/bundler_wrapper exec rake extension:install"
- name: Print extension install report
run: "[ -e ext/install.report ] && cat ext/install.report || echo 'No ext/install.report
file found'"
- name: Print Makefile log file
run: "[ -f ext/mkmf.log ] && cat ext/mkmf.log || echo 'No ext/mkmf.log file
found'"
- name: Run tests
run: "./support/bundler_wrapper exec rake test"
env:
RAILS_ENV: test
JRUBY_OPTS: ''
COV: '1'
BUNDLE_GEMFILE: gemfiles/que-1.gemfile
ruby_3-2-5__que-2_ubuntu-latest:
name: Ruby 3.2.5 - que-2
needs: ruby_3-2-5_ubuntu-latest
runs-on: ubuntu-latest
steps:
Expand All @@ -996,7 +1050,7 @@ jobs:
RAILS_ENV: test
JRUBY_OPTS: ''
COV: '1'
BUNDLE_GEMFILE: gemfiles/que.gemfile
BUNDLE_GEMFILE: gemfiles/que-2.gemfile
ruby_3-2-5__rails-6-1_ubuntu-latest:
name: Ruby 3.2.5 - rails-6.1
needs: ruby_3-2-5_ubuntu-latest
Expand Down Expand Up @@ -1568,8 +1622,35 @@ jobs:
JRUBY_OPTS: ''
COV: '1'
BUNDLE_GEMFILE: gemfiles/psych-4.gemfile
ruby_3-1-6__que_ubuntu-latest:
name: Ruby 3.1.6 - que
ruby_3-1-6__que-1_ubuntu-latest:
name: Ruby 3.1.6 - que-1
needs: ruby_3-1-6_ubuntu-latest
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1.6
bundler-cache: true
- name: Install gem extension
run: "./support/bundler_wrapper exec rake extension:install"
- name: Print extension install report
run: "[ -e ext/install.report ] && cat ext/install.report || echo 'No ext/install.report
file found'"
- name: Print Makefile log file
run: "[ -f ext/mkmf.log ] && cat ext/mkmf.log || echo 'No ext/mkmf.log file
found'"
- name: Run tests
run: "./support/bundler_wrapper exec rake test"
env:
RAILS_ENV: test
JRUBY_OPTS: ''
COV: '1'
BUNDLE_GEMFILE: gemfiles/que-1.gemfile
ruby_3-1-6__que-2_ubuntu-latest:
name: Ruby 3.1.6 - que-2
needs: ruby_3-1-6_ubuntu-latest
runs-on: ubuntu-latest
steps:
Expand All @@ -1594,7 +1675,7 @@ jobs:
RAILS_ENV: test
JRUBY_OPTS: ''
COV: '1'
BUNDLE_GEMFILE: gemfiles/que.gemfile
BUNDLE_GEMFILE: gemfiles/que-2.gemfile
ruby_3-1-6__rails-6-1_ubuntu-latest:
name: Ruby 3.1.6 - rails-6.1
needs: ruby_3-1-6_ubuntu-latest
Expand Down Expand Up @@ -2166,8 +2247,35 @@ jobs:
JRUBY_OPTS: ''
COV: '1'
BUNDLE_GEMFILE: gemfiles/psych-4.gemfile
ruby_3-0-7__que_ubuntu-latest:
name: Ruby 3.0.7 - que
ruby_3-0-7__que-1_ubuntu-latest:
name: Ruby 3.0.7 - que-1
needs: ruby_3-0-7_ubuntu-latest
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0.7
bundler-cache: true
- name: Install gem extension
run: "./support/bundler_wrapper exec rake extension:install"
- name: Print extension install report
run: "[ -e ext/install.report ] && cat ext/install.report || echo 'No ext/install.report
file found'"
- name: Print Makefile log file
run: "[ -f ext/mkmf.log ] && cat ext/mkmf.log || echo 'No ext/mkmf.log file
found'"
- name: Run tests
run: "./support/bundler_wrapper exec rake test"
env:
RAILS_ENV: test
JRUBY_OPTS: ''
COV: '1'
BUNDLE_GEMFILE: gemfiles/que-1.gemfile
ruby_3-0-7__que-2_ubuntu-latest:
name: Ruby 3.0.7 - que-2
needs: ruby_3-0-7_ubuntu-latest
runs-on: ubuntu-latest
steps:
Expand All @@ -2192,7 +2300,7 @@ jobs:
RAILS_ENV: test
JRUBY_OPTS: ''
COV: '1'
BUNDLE_GEMFILE: gemfiles/que.gemfile
BUNDLE_GEMFILE: gemfiles/que-2.gemfile
ruby_3-0-7__rails-6-0_ubuntu-latest:
name: Ruby 3.0.7 - rails-6.0
needs: ruby_3-0-7_ubuntu-latest
Expand Down Expand Up @@ -2683,8 +2791,35 @@ jobs:
JRUBY_OPTS: ''
COV: '1'
BUNDLE_GEMFILE: gemfiles/psych-4.gemfile
ruby_2-7-8__que_ubuntu-latest:
name: Ruby 2.7.8 - que
ruby_2-7-8__que-1_ubuntu-latest:
name: Ruby 2.7.8 - que-1
needs: ruby_2-7-8_ubuntu-latest
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.8
bundler-cache: true
- name: Install gem extension
run: "./support/bundler_wrapper exec rake extension:install"
- name: Print extension install report
run: "[ -e ext/install.report ] && cat ext/install.report || echo 'No ext/install.report
file found'"
- name: Print Makefile log file
run: "[ -f ext/mkmf.log ] && cat ext/mkmf.log || echo 'No ext/mkmf.log file
found'"
- name: Run tests
run: "./support/bundler_wrapper exec rake test"
env:
RAILS_ENV: test
JRUBY_OPTS: ''
COV: '1'
BUNDLE_GEMFILE: gemfiles/que-1.gemfile
ruby_2-7-8__que-2_ubuntu-latest:
name: Ruby 2.7.8 - que-2
needs: ruby_2-7-8_ubuntu-latest
runs-on: ubuntu-latest
steps:
Expand All @@ -2709,7 +2844,7 @@ jobs:
RAILS_ENV: test
JRUBY_OPTS: ''
COV: '1'
BUNDLE_GEMFILE: gemfiles/que.gemfile
BUNDLE_GEMFILE: gemfiles/que-2.gemfile
ruby_2-7-8__rails-6-0_ubuntu-latest:
name: Ruby 2.7.8 - rails-6.0
needs: ruby_2-7-8_ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion build_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ matrix:
- "3.1.6"
- "3.0.7"
- "2.7.8"
- gem: "que"
- gem: "que-1"
- gem: "que-2"
- gem: "rails-6.0"
only:
ruby:
Expand Down
5 changes: 5 additions & 0 deletions gemfiles/que-1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source "https://rubygems.org"

gem "que", "~> 1.0"

gemspec :path => "../"
5 changes: 5 additions & 0 deletions gemfiles/que-2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source "https://rubygems.org"

gem "que", "~> 2.0"

gemspec :path => "../"
5 changes: 0 additions & 5 deletions gemfiles/que.gemfile

This file was deleted.

10 changes: 8 additions & 2 deletions lib/appsignal/integrations/que.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Appsignal
module Integrations
# @api private
module QuePlugin
def _run(*)
def _run(*args)
transaction =
Appsignal::Transaction.create(Appsignal::Transaction::BACKGROUND_JOB)

Expand All @@ -16,7 +16,13 @@ def _run(*)
ensure
local_attrs = respond_to?(:que_attrs) ? que_attrs : attrs
transaction.set_action_if_nil("#{local_attrs[:job_class]}#run")
transaction.add_params_if_nil(local_attrs[:args])
transaction.add_params_if_nil do
{
:arguments => local_attrs[:args]
}.tap do |hash|
hash[:keyword_arguments] = local_attrs[:kwargs] if local_attrs.key?(:kwargs)
end
end
transaction.add_tags(
"id" => local_attrs[:job_id] || local_attrs[:id],
"queue" => local_attrs[:queue],
Expand Down
Loading

0 comments on commit 770bdc0

Please sign in to comment.