-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix!: Drop DelayedJob ActiveRecord in Tests #685
fix!: Drop DelayedJob ActiveRecord in Tests #685
Conversation
The DelayedJob tests suite relied on the ActiveRecord Backend gem for testing, however incompatabilities with ActiveRecord/Rails 7.1 means would result in failures in the test suite. It is not the responsibility of OTel Ruby Instrumentation to ensure compatability of 3rd party gems or ensure our test suite to come up with workarounds for bugs. For this reason I have rewritten the test suite to use the Test backend that Delayed Job used to test the upstream gem. This does introduce one change, the `created_at` attribute, which is _specific_ to the ActiveRecord backend will _no longer_ be emitted. Users that need this event should pin to earlier versions of the gem. There is a risk here that the upstream DelayedJob gem will no longer be included in future releases, but I think that is less likely than to run into incompatabilities with future Rails versions.
end | ||
end | ||
gem_dir = Gem::Specification.find_by_name('delayed_job').gem_dir | ||
require "#{gem_dir}/spec/delayed/serialization/test" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to load this empty file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may not be required since I am using the class instead of a symbol. I will remove it and see if tests pass.
https://github.com/collectiveidea/delayed_job/blob/master/lib/delayed/worker.rb#L67
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this line and the tests pass.
end | ||
gem_dir = Gem::Specification.find_by_name('delayed_job').gem_dir | ||
require "#{gem_dir}/spec/delayed/serialization/test" | ||
require "#{gem_dir}/spec/delayed/backend/test" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO it would make sense to add PR to delayed job to move this file into lib folder since it is useful for testing depending libs. Should I try to open PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be great! Thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lead time seems like it is about 3-4 months in my experience collectiveidea/delayed_job#1169
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
definitely not blocker from my side
# We are compensating for that here in this test... that is a smell | ||
# NoMethodError: undefined method `extract_options!' for [#<ActiveJobPayload:0x0000000108bf5d48>, {}]:Array | ||
# delayed_job-4.1.11/lib/delayed/backend/job_preparer.rb:7:in `initialize'0 | ||
require 'active_support/core_ext/array' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to not just require delayed_job
itself here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delayed_job
is loaded by bundler therefore it is not necessary to load it twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if required properly, it would load this https://github.com/collectiveidea/delayed_job/blob/b66bb64437a8606a414a390531ac73108911434e/lib/delayed_job.rb#L11 and that would load https://github.com/collectiveidea/delayed_job/blob/b66bb64437a8606a414a390531ac73108911434e/lib/delayed/backend/job_preparer.rb#L1
🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is very curious isn't it!
Let me try this again and see what I can figure out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting in that it fails for Rails 7.0 but not for 7.1 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The curious part for me here is that the backtrace clearly states its raised in JobPreparer, which is what requires the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explicitly requiring delayed_job
and still get this error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instrumentation/delayed_job/opentelemetry-instrumentation-delayed_job.gemspec
Outdated
Show resolved
Hide resolved
* chore: use stable toys version * chore: use stable version of toys release code * release: Release 2 gems (open-telemetry#675) * fix: Fix "uses cases" typo in `CONTRIBUTING.md` (open-telemetry#679) * chore(deps-dev): update webmock requirement from ~> 3.18.1 to ~> 3.19.1 in /resources/azure (open-telemetry#653) * chore(deps-dev): update webmock requirement from ~> 3.18.1 to ~> 3.19.1 in /resources/google_cloud_platform (open-telemetry#652) * fix: Remove dependence on activesupport (open-telemetry#687) Instrumentations must not use transitive dependencies used by the library. In this case, relying on the gruf library to load specific ActiveSupport extensions leaves the instrumentation vulnerable to bugs. For this reason I have changed the code to use Enumerable methods instead of ActiveSupport extensions. See open-telemetry#686 * fix!: Drop DelayedJob ActiveRecord in Tests (open-telemetry#685) * fix: Add Rails 7.1 compatability (open-telemetry#684) * chore: Add tests for Rails 7.1 * fix: Rails 7.1 incompatabilities * feat!: obfuscation for mysql2, dalli and postgresql as default option for db_statement (open-telemetry#682) * feat!: fuscation for mysql2, dalli and pg * feat!: update readme * feat!: set db.statement option to obfuscate by default for mysql2, pg and dalli Co-authored-by: Ariel Valentin <[email protected]> * ci: Update test reset code for GraphQL-Ruby 2.1.3 (open-telemetry#691) Fixes open-telemetry#689 * fix: Omit `nil` `net.peer.name` attributes (open-telemetry#693) * ci: upgrade to latest stable version of toys (open-telemetry#694) Fixes errors with incompatible versions defined in the configs: https://github.com/open-telemetry/opentelemetry-ruby-contrib/actions/runs/6534421626/job/17741560442#step:5:10 * release: Release 12 gems (open-telemetry#695) * release: Release 12 gems * opentelemetry-instrumentation-gruf 0.1.1 (was 0.1.0) * opentelemetry-instrumentation-active_support 0.4.3 (was 0.4.2) * opentelemetry-instrumentation-action_view 0.6.1 (was 0.6.0) * opentelemetry-instrumentation-action_pack 0.7.1 (was 0.7.0) * opentelemetry-instrumentation-active_job 0.6.1 (was 0.6.0) * opentelemetry-instrumentation-active_record 0.6.3 (was 0.6.2) * opentelemetry-instrumentation-dalli 0.25.0 (was 0.24.2) * opentelemetry-instrumentation-delayed_job 0.22.0 (was 0.21.0) * opentelemetry-instrumentation-faraday 0.23.3 (was 0.23.2) * opentelemetry-instrumentation-mysql2 0.25.0 (was 0.24.3) * opentelemetry-instrumentation-pg 0.26.0 (was 0.25.3) * opentelemetry-instrumentation-rails 0.28.1 (was 0.28.0) * ci: Trigger builds * fix: Apply suggestions from code review Co-authored-by: Josef Šimánek <[email protected]> * fix: bump gem versions * fix: bump gems --------- Co-authored-by: Ariel Valentin <[email protected]> Co-authored-by: Ariel Valentin <[email protected]> Co-authored-by: Ariel Valentin <[email protected]> Co-authored-by: Josef Šimánek <[email protected]> * chore: Update CODEOWNERS (open-telemetry#692) * chore: Update CODEOWNERS Add @simi and @kaylareopelle and approvers to the list * release: Release opentelemetry-instrumentation-all 0.51.0 (was 0.50.1) (open-telemetry#699) * release: Release opentelemetry-instrumentation-all 0.51.0 (was 0.50.1) * docs: Update all gem Changelog --------- Co-authored-by: Ariel Valentin <[email protected]> Co-authored-by: Ariel Valentin <[email protected]> * feat(trilogy): instrument connect and ping (open-telemetry#704) These can be just as slow as a query if not slower. Co-authored-by: Jean Boussier <[email protected]> * fix: Remove dependency on ActiveSupport core extensions from Grape instrumentation (open-telemetry#706) * release: Release opentelemetry-instrumentation-trilogy 0.57.0 (was 0.56.3) (open-telemetry#708) * release: Release opentelemetry-instrumentation-trilogy 0.57.0 (was 0.56.3) * Empty commit * Release instrumentation-all as well. --------- Co-authored-by: Ariel Valentin <[email protected]> Co-authored-by: Francis Bogsanyi <[email protected]> * chore(deps): update rubocop requirement from ~> 1.56.2 to ~> 1.57.1 (open-telemetry#702) Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](rubocop/rubocop@v1.56.2...v1.57.1) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): update rubocop requirement from ~> 1.56.1 to ~> 1.57.1 in /instrumentation/base (open-telemetry#701) chore(deps-dev): update rubocop requirement from ~> 1.56.1 to ~> 1.57.1 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](rubocop/rubocop@v1.56.1...v1.57.1) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): update rubocop requirement from ~> 1.56.1 to ~> 1.57.1 in /resource_detectors (open-telemetry#700) chore(deps-dev): update rubocop requirement from ~> 1.56.1 to ~> 1.57.1 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](rubocop/rubocop@v1.56.1...v1.57.1) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): update rubocop requirement from ~> 1.56.1 to ~> 1.57.1 in /propagator/ottrace (open-telemetry#698) chore(deps-dev): update rubocop requirement from ~> 1.56.1 to ~> 1.57.1 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](rubocop/rubocop@v1.56.1...v1.57.1) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): update rubocop requirement from ~> 1.56.1 to ~> 1.57.1 in /propagator/xray (open-telemetry#697) chore(deps-dev): update rubocop requirement from ~> 1.56.1 to ~> 1.57.1 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](rubocop/rubocop@v1.56.1...v1.57.1) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Remove opentelemetry-resource_detectors all-in-one gem (open-telemetry#659) * fix: remove call to ActiveSupport::Notifications.notifier#synchronize deprecated in Rails 7.2 (open-telemetry#707) * wrap call to depcrecated private API behind version conditional * convert Rails version string to Gem::Version * fix module access? * check for synchronize method instead of Rails version * add comment --------- Co-authored-by: Ariel Valentin <[email protected]> * chore: Fix linter issue * release: Release 2 gems (open-telemetry#710) * release: Release 2 gems * opentelemetry-instrumentation-grape 0.1.5 (was 0.1.4) * opentelemetry-instrumentation-active_support 0.4.4 (was 0.4.3) * ci: Force --------- Co-authored-by: Ariel Valentin <[email protected]> Co-authored-by: Ariel Valentin <[email protected]> --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Ariel Valentin <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Sam Bostock <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ariel Valentin <[email protected]> Co-authored-by: Xuan <[email protected]> Co-authored-by: Robert Mosolgo <[email protected]> Co-authored-by: Yohei Kitamura <[email protected]> Co-authored-by: Ariel Valentin <[email protected]> Co-authored-by: Josef Šimánek <[email protected]> Co-authored-by: Jean byroot Boussier <[email protected]> Co-authored-by: Jean Boussier <[email protected]> Co-authored-by: Muriel <[email protected]> Co-authored-by: Francis Bogsanyi <[email protected]> Co-authored-by: Sander Jans <[email protected]> Co-authored-by: Katherine Oelsner <[email protected]>
The DelayedJob tests suite relied on the ActiveRecord Backend gem for testing, however incompatabilities with ActiveRecord/Rails 7.1 means would result in failures in the test suite.
It is not the responsibility of OTel Ruby Instrumentation to ensure compatability of 3rd party gems or ensure our test suite to come up with workarounds for bugs.
For this reason I have rewritten the test suite to use the Test backend that Delayed Job used to test the upstream gem.
This does introduce one change, the
created_at
attribute, which is specific to the ActiveRecord backend will no longer be emitted. Users that need this event should pin to earlier versions of the gem.There is a risk here that the upstream DelayedJob gem will no longer be included in future releases, but I think that is less likely than to run into incompatabilities with future Rails versions.
See: #686