Skip to content

Configure server side logging #844

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

Conversation

BenMorganMY
Copy link
Contributor

@BenMorganMY BenMorganMY commented May 26, 2025

This PR allows Shoryuken to be able to configure the logger such as:

Shoryuken.logger = Appsignal::Logger.new('shoryuken')
Shoryuken.logger.formatter = Shoryuken::Logging::WithoutTimestamp.new

This provides some feature parity to Sidekiq and helps developers that are using a service like AppSignal get their logs up there.

https://docs.appsignal.com/logging/platforms/integrations/ruby.html#sidekiq-logger

Summary by CodeRabbit

  • New Features
    • Added the ability to set a custom logger through the main interface.
    • Introduced a new log formatter that omits timestamps for log messages.
  • Refactor
    • Improved logging formatter structure for better code organization and shared functionality.
    • Updated logger handling for improved performance by caching the logger instance.
  • Style
    • Reformatted attribute declarations for improved readability.
  • Chores
    • Updated class inheritance for compatibility with external job queue adapters.
    • Updated gem dependencies to allow more flexible version resolution and added a new runtime dependency.

Copy link

coderabbitai bot commented May 26, 2025

## Walkthrough

The changes introduce enhancements and refactoring to logging and configuration handling in the Shoryuken codebase. These include improved logger delegation, explicit adapter inheritance for Active Job integration, a refactored logging formatter hierarchy with a new base class and additional formatter, and memoization of the logger instance within the options class.

## Changes

| File(s)                                         | Change Summary                                                                                                   |
|------------------------------------------------|-----------------------------------------------------------------------------------------------------------------|
| lib/shoryuken.rb                                | Added `:logger=` to delegated methods for `shoryuken_options` in the `Shoryuken` module.                        |
| lib/shoryuken/extensions/active_job_adapter.rb | Added conditional `BaseAdapter` class; updated `ShoryukenAdapter` to inherit from `BaseAdapter`.                |
| lib/shoryuken/logging.rb                        | Introduced `Base` formatter class; updated `Pretty` to inherit from `Base`; added `WithoutTimestamp` formatter.  |
| lib/shoryuken/options.rb                        | Added `attr_writer :logger`; reformatted attribute accessors; memoized logger instance in `Options` class.      |
| gemfiles/rails_6_1.gemfile                      | Removed fixed version constraint from `pry-byebug` gem declaration.                                             |
| gemfiles/rails_7_0.gemfile                      | Removed `pry` gem; removed version constraints from `pry-byebug` gem declaration.                               |
| shoryuken.gemspec                               | Added new runtime dependency on `mutex_m` gem.                                                                  |

## Poem

> In the warren logs now shine anew,  
> With formatters crisp and options true.  
> A logger passed, a thread ID found,  
> The adapters now on solid ground.  
> Rabbits cheer for code refined—  
> In every hop, new gems we find!  
> 🐇✨
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@BenMorganMY BenMorganMY force-pushed the configure-server-side-logging branch from 152f230 to f6f7683 Compare May 26, 2025 19:25
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
lib/shoryuken/logging.rb (1)

8-8: Minor style improvement: Use single quotes for simple string literal.

The string "sidekiq_tid" doesn't require interpolation, so single quotes would be more appropriate per Ruby style guidelines.

-        Thread.current["sidekiq_tid"] ||= (Thread.current.object_id ^ ::Process.pid).to_s(36)
+        Thread.current['sidekiq_tid'] ||= (Thread.current.object_id ^ ::Process.pid).to_s(36)

Note: The use of 'sidekiq_tid' as the key name appears intentional for compatibility with Sidekiq's thread identification system, which is a reasonable design choice for consistency across similar libraries.

🧰 Tools
🪛 RuboCop (1.75.5)

[convention] 8-8: Prefer single-quoted strings when you don't need string interpolation or special symbols.

(Style/StringLiterals)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7120ac1 and f6f7683.

📒 Files selected for processing (4)
  • lib/shoryuken.rb (1 hunks)
  • lib/shoryuken/extensions/active_job_adapter.rb (1 hunks)
  • lib/shoryuken/logging.rb (2 hunks)
  • lib/shoryuken/options.rb (2 hunks)
🧰 Additional context used
🪛 RuboCop (1.75.5)
lib/shoryuken/logging.rb

[convention] 8-8: Prefer single-quoted strings when you don't need string interpolation or special symbols.

(Style/StringLiterals)

lib/shoryuken/options.rb

[convention] 21-21: Align the arguments of a method call if they span more than one line.

(Layout/ArgumentAlignment)


[convention] 22-22: Align the arguments of a method call if they span more than one line.

(Layout/ArgumentAlignment)


[convention] 23-23: Align the arguments of a method call if they span more than one line.

(Layout/ArgumentAlignment)

🔇 Additional comments (7)
lib/shoryuken.rb (1)

78-78: LGTM! Clean implementation of logger setter delegation.

The addition of :logger= to the delegated methods perfectly complements the existing :logger getter and enables the core functionality described in the PR objectives. This allows users to set a custom logger via Shoryuken.logger = custom_logger as intended.

lib/shoryuken/extensions/active_job_adapter.rb (1)

17-17: Excellent improvement! Explicit inheritance enhances code clarity.

Making the inheritance from ActiveJob::QueueAdapters::AbstractAdapter explicit is a best practice that clearly establishes the adapter's relationship with the ActiveJob framework. This improves code maintainability and follows ActiveJob's recommended adapter pattern.

lib/shoryuken/options.rb (2)

20-25: Well-structured attribute organization and logger configuration support.

The reformatting of the attr_accessor declarations improves readability, and the addition of :logger to attr_writer enables the custom logger configuration feature. This change works seamlessly with the delegation in the main module.

🧰 Tools
🪛 RuboCop (1.75.5)

[convention] 21-21: Align the arguments of a method call if they span more than one line.

(Layout/ArgumentAlignment)


[convention] 22-22: Align the arguments of a method call if they span more than one line.

(Layout/ArgumentAlignment)


[convention] 23-23: Align the arguments of a method call if they span more than one line.

(Layout/ArgumentAlignment)


101-101: Perfect implementation of logger memoization.

The memoization pattern @logger ||= Shoryuken::Logging.logger ensures that once a custom logger is set via the writer method, it will be preserved and returned on subsequent calls. This is exactly the behavior needed for the configurable logger feature.

lib/shoryuken/logging.rb (3)

6-15: Excellent refactoring! Clean base class for shared formatter functionality.

The introduction of the Base class that inherits from ::Logger::Formatter provides a solid foundation for formatter implementations. The shared tid and context methods eliminate code duplication and create a consistent interface.

🧰 Tools
🪛 RuboCop (1.75.5)

[convention] 8-8: Prefer single-quoted strings when you don't need string interpolation or special symbols.

(Style/StringLiterals)


17-22: Good refactoring of Pretty formatter to use base class.

The Pretty formatter now leverages the shared tid method from the base class, which improves maintainability and consistency across formatters.


24-28: Great addition! WithoutTimestamp formatter provides Sidekiq feature parity.

The new WithoutTimestamp formatter perfectly aligns with the PR objective of providing feature parity with Sidekiq's logging capabilities. The format pid=#{Process.pid} tid=#{tid}#{context} #{severity}: #{message} is clean and informative without the timestamp.

@mensfeld mensfeld assigned mensfeld and BenMorganMY and unassigned mensfeld May 26, 2025
@mensfeld mensfeld self-requested a review May 26, 2025 20:10
Copy link
Collaborator

@mensfeld mensfeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do like the idea and most of the implementation, I do not like the sidekiq part though.

@BenMorganMY BenMorganMY force-pushed the configure-server-side-logging branch from f6f7683 to dd2334b Compare June 2, 2025 17:10
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
lib/shoryuken/options.rb (1)

20-24: Fix argument alignment to comply with RuboCop conventions.

The reformatted attr_accessor declarations improve readability, but the alignment doesn't follow RuboCop conventions.

Apply this diff to fix the alignment:

-    attr_accessor :active_job_queue_name_prefixing, :cache_visibility_timeout,
-      :groups, :launcher_executor, :reloader, :enable_reloading,
-      :start_callback, :stop_callback, :worker_executor, :worker_registry,
-      :exception_handlers
+    attr_accessor :active_job_queue_name_prefixing, :cache_visibility_timeout,
+                  :groups, :launcher_executor, :reloader, :enable_reloading,
+                  :start_callback, :stop_callback, :worker_executor, :worker_registry,
+                  :exception_handlers
🧰 Tools
🪛 RuboCop (1.75.5)

[convention] 21-21: Align the arguments of a method call if they span more than one line.

(Layout/ArgumentAlignment)


[convention] 22-22: Align the arguments of a method call if they span more than one line.

(Layout/ArgumentAlignment)


[convention] 23-23: Align the arguments of a method call if they span more than one line.

(Layout/ArgumentAlignment)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f6f7683 and dd2334b.

📒 Files selected for processing (4)
  • lib/shoryuken.rb (1 hunks)
  • lib/shoryuken/extensions/active_job_adapter.rb (1 hunks)
  • lib/shoryuken/logging.rb (2 hunks)
  • lib/shoryuken/options.rb (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • lib/shoryuken/extensions/active_job_adapter.rb
  • lib/shoryuken.rb
  • lib/shoryuken/logging.rb
🧰 Additional context used
🪛 RuboCop (1.75.5)
lib/shoryuken/options.rb

[convention] 21-21: Align the arguments of a method call if they span more than one line.

(Layout/ArgumentAlignment)


[convention] 22-22: Align the arguments of a method call if they span more than one line.

(Layout/ArgumentAlignment)


[convention] 23-23: Align the arguments of a method call if they span more than one line.

(Layout/ArgumentAlignment)

🔇 Additional comments (2)
lib/shoryuken/options.rb (2)

25-25: LGTM! Excellent addition for configurable logging.

The attr_writer :logger enables external assignment of custom loggers, which perfectly aligns with the PR objective to provide feature parity with Sidekiq's logging capabilities.


100-102:

❌ Incorrect review comment

Consider thread safety for the memoization pattern.

The logger memoization implementation correctly allows custom loggers to be cached and reused. However, the @logger ||= value pattern is not thread-safe in Ruby and could lead to race conditions in multi-threaded environments.

Consider using a thread-safe memoization approach:

-    def logger
-      @logger ||= Shoryuken::Logging.logger
-    end
+    def logger
+      return @logger if defined?(@logger)
+      @logger_mutex ||= Mutex.new
+      @logger_mutex.synchronize do
+        @logger ||= Shoryuken::Logging.logger
+      end
+    end

Or verify if Shoryuken's architecture ensures single-threaded access to the Options instance during logger configuration.


🏁 Script executed:

#!/bin/bash
# Search for concurrent access patterns to Options class
rg -A 3 -B 3 "Options\.new|\.logger\s*=" --type ruby

Length of output: 620


🏁 Script executed:

#!/bin/bash
# Display the start of the Options class including the logger method context
sed -n '1,200p' lib/shoryuken/options.rb

Length of output: 5105


No thread‐safety issue with Options#logger

The Options instance is created and fully configured on the main thread before any worker threads start, so there’s no concurrent access to @logger. In practice, even if two threads did race in the ||= assignment, they’d both cache the same Shoryuken::Logging.logger instance—and the worst‐case is a redundant initializer call, not a broken state.

Moreover, wrapping Options#logger in a Mutex wouldn’t fix the underlying pattern in Shoryuken::Logging.logger, which uses the same ||= memoization. If you really need thread‐safe memoization, you’d have to synchronize inside Shoryuken::Logging.logger itself.

No changes required here.

Likely an incorrect or invalid review comment.

@mensfeld
Copy link
Collaborator

Thanks. Sorry I missed that 🙏

@mensfeld mensfeld self-requested a review June 16, 2025 07:41
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
lib/shoryuken/extensions/active_job_adapter.rb (1)

80-86: Missing require 'digest' can trigger NameError

Digest::SHA256 is referenced without ensuring the digest stdlib is loaded. In minimal Ruby environments the constant will be absent, raising NameError at runtime.

+require 'digest'  # needed for Digest::SHA256 below

Place it near the other top-level requires.

🧹 Nitpick comments (1)
lib/shoryuken/extensions/active_job_adapter.rb (1)

9-13: Minor RuboCop style nit – prefer single quotes

RuboCop flags the double-quoted string '6.1.0' where interpolation isn’t used:

- if ActiveJob.version > Gem::Version.new("6.1.0")
+ if ActiveJob.version > Gem::Version.new('6.1.0')

Purely cosmetic but keeps the codebase consistent.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b68191 and d9d7f77.

📒 Files selected for processing (1)
  • lib/shoryuken/extensions/active_job_adapter.rb (2 hunks)
🧰 Additional context used
🪛 RuboCop (1.75.5)
lib/shoryuken/extensions/active_job_adapter.rb

[convention] 9-9: Prefer single-quoted strings when you don't need string interpolation or special symbols.

(Style/StringLiterals)

An error occurred while loading ./spec/shoryuken/extensions/active_job_base_spec.rb. - Did you mean?
                    rspec ./spec/shoryuken/extensions/active_job_wrapper_spec.rb
                    rspec ./spec/shoryuken/extensions/active_job_adapter_spec.rb

Failure/Error: require 'active_job'

LoadError:
  cannot load such file -- mutex_m
# ./spec/shoryuken/extensions/active_job_base_spec.rb:2:in '<top (required)>'
@BenMorganMY
Copy link
Contributor Author

@mensfeld can you take another look at this?

@mensfeld
Copy link
Collaborator

mensfeld commented Jul 3, 2025

If all except 6.1 pass I will retarget and remove 6.1 support.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
lib/shoryuken/extensions/active_job_adapter.rb (1)

8-8: Use single quotes for string literals.

The string doesn't require interpolation or special symbols, so single quotes are preferred by Ruby style conventions.

-    if ActiveJob.version >= Gem::Version.new("7.0.0")
+    if ActiveJob.version >= Gem::Version.new('7.0.0')
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d9d7f77 and 8de0086.

📒 Files selected for processing (4)
  • gemfiles/rails_6_1.gemfile (1 hunks)
  • gemfiles/rails_7_0.gemfile (1 hunks)
  • lib/shoryuken/extensions/active_job_adapter.rb (2 hunks)
  • shoryuken.gemspec (1 hunks)
🧰 Additional context used
🪛 RuboCop (1.75.5)
gemfiles/rails_7_0.gemfile

[convention] 14-14: Prefer single-quoted strings when you don't need string interpolation or special symbols.

(Style/StringLiterals)

gemfiles/rails_6_1.gemfile

[convention] 14-14: Prefer single-quoted strings when you don't need string interpolation or special symbols.

(Style/StringLiterals)

lib/shoryuken/extensions/active_job_adapter.rb

[convention] 8-8: Prefer single-quoted strings when you don't need string interpolation or special symbols.

(Style/StringLiterals)

🪛 GitHub Actions: Specs
lib/shoryuken/extensions/active_job_adapter.rb

[error] 9-9: NameError: uninitialized constant ActiveJob::QueueAdapters::AbstractAdapter. This caused multiple spec files to fail loading.

🔇 Additional comments (3)
lib/shoryuken/extensions/active_job_adapter.rb (1)

23-23: Excellent approach for version-agnostic inheritance.

The change to inherit from BaseAdapter provides clean version compatibility across different ActiveJob versions. This aligns well with the PR objectives of improving integration capabilities.

gemfiles/rails_7_0.gemfile (1)

14-14: Fix string quote style and verify the relevance of Gemfile changes.

The RuboCop hint suggests using single quotes for consistency. However, more importantly, this Gemfile change appears unrelated to the PR's stated objective of "Configure server side logging" for Shoryuken.

Apply this diff to fix the string quote style:

-  gem "pry-byebug"
+  gem 'pry-byebug'

Please verify that these Gemfile changes are intentionally part of this logging configuration PR, as they appear to be unrelated development dependency updates.

Likely an incorrect or invalid review comment.

gemfiles/rails_6_1.gemfile (1)

14-14: Fix string quote style and verify the relevance of Gemfile changes.

Similar to the Rails 7.0 Gemfile, this change removes version constraints from development dependencies but appears unrelated to the PR's logging configuration objective.

Apply this diff to fix the string quote style:

-  gem "pry-byebug"
+  gem 'pry-byebug'

These Gemfile changes across both Rails versions suggest they may be incidental updates rather than core changes for the logging configuration feature.

Likely an incorrect or invalid review comment.

Comment on lines +8 to +12
if ActiveJob.version >= Gem::Version.new("7.0.0")
class BaseAdapter < ActiveJob::QueueAdapters::AbstractAdapter; end
else
class BaseAdapter; end
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix the AbstractAdapter availability issue causing pipeline failures.

The pipeline is failing with NameError: uninitialized constant ActiveJob::QueueAdapters::AbstractAdapter even when the version check passes. This suggests AbstractAdapter may not be autoloaded when this code executes.

Consider a more defensive approach that safely checks for the constant's existence:

-    if ActiveJob.version >= Gem::Version.new("7.0.0")
-      class BaseAdapter < ActiveJob::QueueAdapters::AbstractAdapter; end
-    else
-      class BaseAdapter; end
-    end
+    if ActiveJob.version >= Gem::Version.new("7.0.0") && 
+       defined?(ActiveJob::QueueAdapters::AbstractAdapter)
+      class BaseAdapter < ActiveJob::QueueAdapters::AbstractAdapter; end
+    else
+      class BaseAdapter; end
+    end

Alternatively, you could wrap the inheritance in a begin/rescue block to handle cases where the constant is not available:

+    begin
+      if ActiveJob.version >= Gem::Version.new("7.0.0")
+        class BaseAdapter < ActiveJob::QueueAdapters::AbstractAdapter; end
+      else
+        class BaseAdapter; end
+      end
+    rescue NameError
+      class BaseAdapter; end
+    end
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if ActiveJob.version >= Gem::Version.new("7.0.0")
class BaseAdapter < ActiveJob::QueueAdapters::AbstractAdapter; end
else
class BaseAdapter; end
end
if ActiveJob.version >= Gem::Version.new("7.0.0") &&
defined?(ActiveJob::QueueAdapters::AbstractAdapter)
class BaseAdapter < ActiveJob::QueueAdapters::AbstractAdapter; end
else
class BaseAdapter; end
end
🧰 Tools
🪛 RuboCop (1.75.5)

[convention] 8-8: Prefer single-quoted strings when you don't need string interpolation or special symbols.

(Style/StringLiterals)

🪛 GitHub Actions: Specs

[error] 9-9: NameError: uninitialized constant ActiveJob::QueueAdapters::AbstractAdapter. This caused multiple spec files to fail loading.

🤖 Prompt for AI Agents
In lib/shoryuken/extensions/active_job_adapter.rb around lines 8 to 12, the code
assumes ActiveJob::QueueAdapters::AbstractAdapter is always defined when
ActiveJob version is 7.0.0 or higher, causing a NameError if it's not
autoloaded. To fix this, modify the code to first check if the AbstractAdapter
constant is defined before inheriting from it, or wrap the inheritance in a
begin/rescue block to fallback safely if the constant is missing, ensuring the
class definition does not raise an error.

@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rspec'

spec.add_dependency 'mutex_m'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Redundant dependency on mutex_m – please confirm necessity

mutex_m has been bundled with Ruby’s stdlib/default-gem set for many years (simply require 'mutex_m' works out of the box on ≥3.0). Declaring it as an external runtime dependency forces an extra gem install and introduces the risk of version drift or resolution failures in minimal images.

-  spec.add_dependency 'mutex_m'
+# `mutex_m` ships with Ruby; no separate gem needed unless you target a Ruby build
+# that deliberately omits default gems.

Unless you have evidence of environments where the default gem is absent, consider removing this line.


🏁 Script executed:

#!/bin/bash
set -e
# Locate the gemspec file
gemspec_path=$(fd shoryuken.gemspec | head -n1)
echo "Found gemspec: $gemspec_path"
echo -e "\n--- Start of gemspec (first 200 lines) ---"
sed -n '1,200p' "$gemspec_path"
echo -e "\n--- Ruby version requirement ---"
grep -n "required_ruby_version" "$gemspec_path" || echo "No required_ruby_version specified"
echo -e "\n--- Dependency list ---"
grep -n "add_dependency" "$gemspec_path"

Length of output: 1827


Remove redundant mutex_m dependency

Since this gem already requires Ruby ≥3.0 (where mutex_m ships as a default stdlib gem), you don’t need to declare it as an external runtime dependency. Please remove the following line:

• File shoryuken.gemspec, line 25:

- spec.add_dependency 'mutex_m'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
spec.add_dependency 'mutex_m'
🤖 Prompt for AI Agents
In shoryuken.gemspec at line 25, remove the line that adds 'mutex_m' as a
dependency because Ruby 3.0 and above include 'mutex_m' as a default standard
library, making this declaration redundant.

@mensfeld mensfeld changed the base branch from main to server-side-logging July 3, 2025 14:12
@mensfeld
Copy link
Collaborator

mensfeld commented Jul 3, 2025

yeah let me merge it there and deal with this separately

@mensfeld mensfeld merged commit 0c1c09f into ruby-shoryuken:server-side-logging Jul 3, 2025
6 of 11 checks passed
@mensfeld mensfeld mentioned this pull request Jul 3, 2025
mensfeld added a commit that referenced this pull request Jul 3, 2025
* Configure server side logging (#844)

* add the ability to be able to set the logger

* add a without timestamp class

* shoryuken adapter extends from active job queue adapter

* use shoryuken_tid instead

* ensure the abstract adapter is loaded

* use a conditional base adapter to resolve rails 6.1 not having an abstract adapter

* use active job version

* appraisal install

* fix issue with mutex_m not being loaded

An error occurred while loading ./spec/shoryuken/extensions/active_job_base_spec.rb. - Did you mean?
                    rspec ./spec/shoryuken/extensions/active_job_wrapper_spec.rb
                    rspec ./spec/shoryuken/extensions/active_job_adapter_spec.rb

Failure/Error: require 'active_job'

LoadError:
  cannot load such file -- mutex_m
# ./spec/shoryuken/extensions/active_job_base_spec.rb:2:in '<top (required)>'

* fix version comparison and no need to load abstract adapter explicitly

---------

Co-authored-by: Maciej Mensfeld <[email protected]>

* remove rails 6.1 and ruby 3.0 support

* use directly the aj adapter

---------

Co-authored-by: Ben A. Morgan <[email protected]>
@Copilot Copilot AI mentioned this pull request Jul 3, 2025
@BenMorganMY BenMorganMY deleted the configure-server-side-logging branch July 4, 2025 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants