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 djongo #2438

Closed
InterstellarStella opened this issue Oct 11, 2023 · 6 comments · Fixed by #2441
Closed

Add support for djongo #2438

InterstellarStella opened this issue Oct 11, 2023 · 6 comments · Fixed by #2441
Assignees
Labels
Integration: Django Type: Bug Something isn't working

Comments

@InterstellarStella
Copy link

Problem Statement

It looks like when we add Sentry to a Django application with MongoDB, Djongo seems to be monkeypatching the connection object that we rely on, causing the django integration to break. The error thrown is:

File "/Users/user/opt/anaconda3/envs/ZETA/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1175, in execute_sql
cursor.execute(sql, params)
File "/Users/user/opt/anaconda3/envs/ZETA/lib/python3.8/site-packages/django/db/backends/utils.py", line 98, in execute
return super().execute(sql, params)
File "/Users/user/opt/anaconda3/envs/ZETA/lib/python3.8/site-packages/sentry_sdk/integrations/django/__init__.py", line 615, in execute
_set_db_data(span, self)
File "/Users/user/opt/anaconda3/envs/ZETA/lib/python3.8/site-packages/sentry_sdk/integrations/django/__init__.py", line 657, in _set_db_data
cursor_or_db.connection.get_dsn_parameters()
File "/Users/user/opt/anaconda3/envs/ZETA/lib/python3.8/site-packages/pymongo/collection.py", line 3491, in __call__
raise TypeError("'Collection' object is not callable. If you meant to "
TypeError: 'Collection' object is not callable. If you meant to call the 'get_dsn_parameters' method on a 'Collection' object it is failing because no such method exists.

Solution Brainstorm

We should add support for Djongo so that adding Sentry's Django SDK works without any issues.

@InterstellarStella InterstellarStella added the Enhancement New feature or request label Oct 11, 2023
@sentrivana
Copy link
Contributor

@InterstellarStella Looking at the stacktrace it seems like they're on a slightly older Python SDK version. Upgrading to 1.32.0 might help because we're now a bit more careful about accessing the params: https://github.com/getsentry/sentry-python/blob/master/sentry_sdk/integrations/django/__init__.py#L668-L673

@omarsagheer
Copy link

omarsagheer commented Oct 11, 2023

@sentrivana I went to the place you highlighted in the code and updated that part to immediately go to the else block.
connection_params = ( db.get_connection_params() )

It is working great. For now we need to update it locally for everyone in the team until you guys find a solution.

Thank you for your help @InterstellarStella @sentrivana.

@sentrivana sentrivana removed the Enhancement New feature or request label Oct 11, 2023
@sentrivana
Copy link
Contributor

Hey @omarsagheer, thanks for the follow up! Just to clarify, you're on SDK version 1.32.0 and it still required the patch you mentioned?

@omarsagheer
Copy link

hello @sentrivana yes I updated and tried, same issue, still needed to manually update that part I mentioned.

@sentrivana
Copy link
Contributor

Thanks! We'll look into fixing that in the next release.

@omarsagheer
Copy link

Great! Thank you for your time and effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Integration: Django Type: Bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants