Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Semantic Logger + Sidekiq 7 #243

Closed
Petercopter opened this issue Oct 31, 2022 · 3 comments
Closed

Semantic Logger + Sidekiq 7 #243

Petercopter opened this issue Oct 31, 2022 · 3 comments

Comments

@Petercopter
Copy link

Petercopter commented Oct 31, 2022

Looks like there's a problem with the new Sidekiq 7 logging:

Environment

Ruby 3.1.2
Rails 7.0.4
Puma 5.6.5
rspec-rails 6.0.1
Sidekiq 7.0

config/initializers/semantic_logger.rb:

SemanticLogger.add_appender(appender: :new_relic)

Expected Behavior

Test suite should run without errors

Actual Behavior

❯ bundle exec rspec

An error occurred while loading ./spec/channels/customers/notifications_channel_spec.rb.
Failure/Error: require File.expand_path('../config/environment', __dir__)

NoMethodError:
  undefined method `logger=' for Sidekiq:Module

        Sidekiq.logger       = SemanticLogger[Sidekiq] if defined?(Sidekiq)
               ^^^^^^^^^^^^^^^
  Did you mean?  logger
# ./config/environment.rb:5:in `<top (required)>'
# ./spec/rails_helper.rb:5:in `require'
# ./spec/rails_helper.rb:5:in `<top (required)>'
# ./spec/channels/customers/notifications_channel_spec.rb:1:in `require'
# ./spec/channels/customers/notifications_channel_spec.rb:1:in `<top (required)>'

Edit: Mike Perham has commented on the linked issue about what is needed to support Sidekiq 7.

@reidmorrison
Copy link
Owner

Since you are using Sidekiq 7, can you find out how to replace its default logger if it is no longer Sidekiq.logger=?

@reidmorrison
Copy link
Owner

reidmorrison commented Nov 6, 2022

Until we have more info on how to support Sidekiq 7, this commit will turn off built-in logging support for Sidekiq v7, allowing it to be setup manually: reidmorrison/rails_semantic_logger@a64c480

To hazard a guess after pointing to the Rails Semantic Logger master branch, then something like the following would work:

Sidekiq.configure_{client,server,embed} do |config|
  config.logger = SemanticLogger[Sidekiq]
end

@Petercopter
Copy link
Author

Confirmed 👍 . Switching to that commit for rails_semantic_logger and adding

Sidekiq.configure_client do |config|
  config.logger = SemanticLogger[Sidekiq]
end

Sidekiq.configure_server do |config|
  config.logger = SemanticLogger[Sidekiq]
end

to config/initializers/sidekiq.rb did the trick.

Repository owner locked and limited conversation to collaborators Nov 10, 2022
@reidmorrison reidmorrison converted this issue into discussion #246 Nov 10, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

2 participants