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

Active Job reporter reports incorrect data if a job is run within another job via perform_now #2467

Open
jonleighton opened this issue Nov 20, 2024 · 1 comment

Comments

@jonleighton
Copy link

Issue Description

Sentry's Active Job reporting code works by prepending a module to overload the perform_now method.

This has the outcome that if one job runs the code in another job via perform_now, and an error occurs, the transaction and context will be reported as the inner job, even though it's the outer job being run.

Similarly, we may not even be in a job run at all, e.g. if some controller calls perform_now on a job, the context will be wrong. It will look like the error occurred in a worker process, when it actually occurred in a web process.

Reproduction Steps

class AJob < ApplicationJob
  def perform
    BJob.perform_now
  end
end

class BJob < ApplicationJob
  def perform
    raise "omg"
  end
end

Call AJob.perform_later.

Expected Behavior

Transaction/context is reported from AJob.

Actual Behavior

Transaction/context is reported from BJob.

Ruby Version

3.3.5

SDK Version

5.21.0

Integration and Its Version

No response

Sentry Config

No response

@sl0thentr0py
Copy link
Member

right, technically if we're in the same process and not in the worker, we could just start a span instead. I'll have to see what the best way of detecting this is though, or maybe not patch perform_now but the enqueue/execute separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting for: Product Owner
Development

No branches or pull requests

2 participants