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

sentry-rails 4.3.0 triggers endless series of transaction traces when using Sentry::SendEventJob #1348

Closed
anderscarling opened this issue Mar 19, 2021 · 8 comments

Comments

@anderscarling
Copy link

Describe the bug

Submitting an error using Sentry::SendEventJob will cause an infinite series of transaction traces to be submitted to sentry.

Error goes away when appending relevant lines in Sentry::Rails::ActiveJobExtensions#capture_and_reraise_with_sentry (those added in #1304) with unless job.class == Sentry::SendEventJob.

To Reproduce

Setup sentry with:

  config.async = lambda do |event, hint|
    Sentry::SendEventJob.perform_later(event, hint)
  end

Cause an exception to be reported.

Expected behavior

Sentry::SendEventJob should report the error, then do no more work.

Actual behavior

For each run of Sentry::SendEventJob a transaction trace will be created, which will trigger another Sentry::SendEventJob to submit the transaction. This will repeat forever.

Environment

  • Ruby Version: 3.0.0
  • SDK Version: 4.3.0
  • Integration Versions (if any):
  • e.g. Rails 6.1
@st0012
Copy link
Collaborator

st0012 commented Mar 19, 2021

@anderscarling thanks for reporting this, we've released sentry-rails 4.3.1 to address the issue 🙂

@wladimirgramacho
Copy link

wladimirgramacho commented Mar 19, 2021

@st0012 I just tried to update the sentry-rails gem to 4.3.1 and the erros still remain. I have the same config @anderscarling showed in the description. Here is the sentry error. We are holding onto the 4.2.2 version

@st0012
Copy link
Collaborator

st0012 commented Mar 19, 2021

@wladimirgramacho do you still receive transactions of SendEventJob after upgrading the gem? the issue you describe looks like a different issue, which probably happens like this:

  1. your background jobs also create transactions after the upgrade
  2. the high number (I assume) of background job transactions triggers rate limit
  3. the SendEventJob worker fails because of the 429 response
  4. the exception enqueues another SendEventJob
    • this is a bug because Sentry::ExternalError shouldn't be sent to Sentry. I'll fix it.
  5. 3 and 4 repeats

can you help me confirm the theory by setting this:

  config.traces_sampler = lambda do |sampling_context|
    transaction_context = sampling_context[:transaction_context]

    op = transaction_context[:op]
    if op.match? /request/
      0.3 # set the rate you originally have
    elsif op.match? /active_job/ || op.match? /sidekiq/
      0.01 # set a lower rate for background jobs
    end
  end

and see

  • does the rate limiting error occur again?
  • do you still see tracing data for SendEventJob

@st0012
Copy link
Collaborator

st0012 commented Mar 20, 2021

@anderscarling @wladimirgramacho sorry I just found out that the PR was missed from the 4.3.1 release 🤦‍♂️ I'll make 4.3.2 release as soon as possible.

@st0012 st0012 modified the milestones: sentry-rails-4.3.1, 4.4.0 Mar 20, 2021
@st0012
Copy link
Collaborator

st0012 commented Mar 22, 2021

sorry for delay, the original fix has been released in 4.3.2 now.

@wladimirgramacho please let me know if you still see the same problem after the upgrade 🙂

@wladimirgramacho
Copy link

wladimirgramacho commented Mar 22, 2021

@st0012 We have just upgraded and the errors happened again 😕

The error that happens is due to the Sentry::ExternalError. Do you have any updates on this bug fix?

@anderscarling
Copy link
Author

It seems to work as expected for me now, so could be a different issue.

@st0012
Copy link
Collaborator

st0012 commented Mar 22, 2021

@wladimirgramacho the fix is on sentry-ruby's master already. but it'll be released later next week with other corrections.
here's a quick fix for it:

Sentry.init do |config|
  config.excluded_exceptions << "Sentry::ExternalError" # TODO: Remove this line after upgrading sentry-ruby
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants