Skip to content
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

Add support for logging background job enqueue callers #47839

Merged
merged 1 commit into from Apr 3, 2023

Conversation

fatkodima
Copy link
Member

I recently released a gem (https://github.com/fatkodima/job_enqueue_logger) for logging when background jobs are enqueued (additionally with backtraces). Idea is similar to a familiar SQL query tracing, but for background jobs. Getting such info is useful for debugging and generally understanding whats going on in a large app. There was a warm welcome of such a feature on reddit.

That gem works only with raw background processors, which are not logging any info when the job is enqueued. Fortunately, ActiveJob already logs such an info, but is missing backtraces. I was suggested to implement that upstream, so this PR adds backtraces on top of that.

It looks like this:

Enqueued AvatarThumbnailsJob (Job ID: ab528951-41fb-4c48-9129-3171791c27d6) to Sidekiq(default) with arguments: 1092412064
↳ app/models/user.rb:421:in `generate_avatar_thumbnails'

cc @byroot (as we discussed this)

Copy link
Member

@byroot byroot left a comment

Choose a reason for hiding this comment

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

:chef-kiss:

@byroot byroot merged commit b113b7f into rails:main Apr 3, 2023
8 checks passed
@fatkodima fatkodima deleted the verbose-enqueue-logs branch April 3, 2023 10:15
zzak added a commit to zzak/rails that referenced this pull request Apr 5, 2023
danielvdao pushed a commit to danielvdao/rails that referenced this pull request May 1, 2023
danielvdao pushed a commit to danielvdao/rails that referenced this pull request May 1, 2023
danielvdao pushed a commit to danielvdao/rails that referenced this pull request May 1, 2023
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.

None yet

2 participants