Skip to content

Fix kombu crash when using sentry & setting parsing #1359

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

Merged
merged 11 commits into from
Apr 24, 2025

Conversation

hmstepanek
Copy link
Contributor

@hmstepanek hmstepanek commented Apr 17, 2025

Overview

Because Sentry applies a proxy wrapper around the Producer.publish method, when we tried to apply the bind_args, it did not pickup the wrapped signature correctly-the instance was missing and so the value for the body was set as the value of self. Instead use a hardcoded bind to avoid this issue.

Fix missing parsing of config file instrumentation settings.

This is a fix for #1347.

@hmstepanek hmstepanek requested a review from a team as a code owner April 17, 2025 00:46
Copy link

github-actions bot commented Apr 17, 2025

🦙 MegaLinter status: ✅ SUCCESS

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ ACTION actionlint 6 0 0 0.47s
✅ MARKDOWN markdownlint 7 0 0 0 0.99s
✅ MARKDOWN markdown-link-check 7 0 0 9.2s
✅ PYTHON ruff 893 0 0 0 0.59s
✅ PYTHON ruff-format 893 0 0 0 0.27s
✅ YAML prettier 13 0 0 0 1.09s
✅ YAML v8r 13 0 0 4.64s
✅ YAML yamllint 13 0 0 0.56s

See detailed report in MegaLinter reports

MegaLinter is graciously provided by OX Security

@codecov-commenter
Copy link

codecov-commenter commented Apr 17, 2025

Codecov Report

Attention: Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.

Project coverage is 79.90%. Comparing base (911aeee) to head (a54a93d).

Files with missing lines Patch % Lines
newrelic/hooks/messagebroker_kombu.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1359      +/-   ##
==========================================
+ Coverage   79.46%   79.90%   +0.44%     
==========================================
  Files         204      204              
  Lines       22832    22842      +10     
  Branches     3618     3618              
==========================================
+ Hits        18144    18253     +109     
+ Misses       3500     3392     -108     
- Partials     1188     1197       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mergify mergify bot removed the tests-failing label Apr 17, 2025
@hmstepanek hmstepanek changed the title Fix kombu crash when using sentry Fix kombu crash when using sentry & setting parsing Apr 17, 2025
def wrap_Producer_publish(wrapped, instance, args, kwargs):
transaction = current_transaction()

if transaction is None:
return wrapped(*args, **kwargs)

bound_args = bind_args(wrapped, args, kwargs)
bound_args = bind_publish(*args, **kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
bound_args = bind_publish(*args, **kwargs)
try:
bound_args = bind_publish(*args, **kwargs)
except Exception:
bound_args = None
if not bound_args:
return wrapped(*args, **kwargs)

I'm worried this will crash on other versions of Kombu since we only test the latest. Can we wrap it in a try/except clause like so?

This could use an exception message logged to debug as well.

@hmstepanek hmstepanek force-pushed the fix-kombu-sentry-crash branch from 5ca3e3f to 164015e Compare April 22, 2025 22:39
@hmstepanek hmstepanek requested a review from TimPansino April 22, 2025 22:55
TimPansino
TimPansino previously approved these changes Apr 22, 2025
@TimPansino TimPansino merged commit a330873 into main Apr 24, 2025
57 of 59 checks passed
@TimPansino TimPansino deleted the fix-kombu-sentry-crash branch April 24, 2025 18:42
@mergify mergify bot removed the tests-failing label Apr 24, 2025
@TimPansino TimPansino added this to the v10.10.0 milestone Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants