Repository navigation
Closed
Description
How do you use Sentry?
Sentry Saas (sentry.io)
Version
2.2.0
Steps to Reproduce
I tried to query as usual with django-clickhouse-backend
as simple as CHFoo.objects.first()
and I got AttributeError: 'Connection' object has no attribute '_sentry_span' exception.
It worked before when using version 1.45.0
I have tried to bump the clickhouse-driver and django-clickhouse-backend, bu no luck
pip:
sentry-sdk==2.2.0
clickhouse-driver==0.2.7
clickhouse-pool==0.5.3
django-clickhouse-backend==1.1.7
Expected Result
Should work as usual
Actual Result
>>> CHVoucher.objects.first()
Traceback (most recent call last):
File "<input>", line 1, in <module>
CHVoucher.objects.first()
File "/home/marsha/venv/stamps/lib/python3.10/site-packages/django/db/models/manager.py", line 87, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/marsha/venv/stamps/lib/python3.10/site-packages/django/db/models/query.py", line 1057, in first
for obj in queryset[:1]:
File "/home/marsha/venv/stamps/lib/python3.10/site-packages/django/db/models/query.py", line 398, in __iter__
self._fetch_all()
File "/home/marsha/venv/stamps/lib/python3.10/site-packages/django/db/models/query.py", line 1881, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/home/marsha/venv/stamps/lib/python3.10/site-packages/django/db/models/query.py", line 91, in __iter__
results = compiler.execute_sql(
File "/home/marsha/venv/stamps/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1562, in execute_sql
cursor.execute(sql, params)
File "/home/marsha/venv/stamps/lib/python3.10/site-packages/django/db/backends/utils.py", line 102, in execute
return super().execute(sql, params)
File "/home/marsha/venv/stamps/lib/python3.10/site-packages/sentry_sdk/utils.py", line 1711, in runner
return sentry_patched_function(*args, **kwargs)
File "/home/marsha/venv/stamps/lib/python3.10/site-packages/sentry_sdk/integrations/django/__init__.py", line 629, in execute
result = real_execute(self, sql, params)
File "/home/marsha/venv/stamps/lib/python3.10/site-packages/django/db/backends/utils.py", line 67, in execute
return self._execute_with_wrappers(
File "/home/marsha/venv/stamps/lib/python3.10/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/marsha/venv/stamps/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
File "/home/marsha/venv/stamps/lib/python3.10/site-packages/clickhouse_backend/driver/connection.py", line 108, in execute
super().execute(operation, parameters)
File "/home/marsha/venv/stamps/lib/python3.10/site-packages/clickhouse_driver/dbapi/cursor.py", line 111, in execute
response = execute(
File "/home/marsha/venv/stamps/lib/python3.10/site-packages/clickhouse_backend/driver/client.py", line 53, in execute
rv = self.process_ordinary_query(
File "/home/marsha/venv/stamps/lib/python3.10/site-packages/clickhouse_driver/client.py", line 580, in process_ordinary_query
return self.receive_result(with_column_types=with_column_types,
File "/home/marsha/venv/stamps/lib/python3.10/site-packages/sentry_sdk/integrations/clickhouse_driver.py", line 109, in _inner_end
span = instance.connection._sentry_span # type: ignore[attr-defined]
AttributeError: 'Connection' object has no attribute '_sentry_span'
>>>
Reacted by Selwin Ong
Metadata
Metadata
Assignees
Projects
- StatusShow more project fieldsWaiting for: Product Owner
Activity
[-]Clickhouse integration not working after upgrading from 1.45.0[/-][+][Django] Clickhouse integration not working after upgrading from 1.45.0[/+]sentrivana commentedon May 21, 2024
Thanks @marsha97, looks like a possible regression in 2.0, we will take a look asap.
sentrivana commentedon May 22, 2024
The reason for this is that in SDK 2.0+ we're now auto-enabling the
ClickhouseIntegrationif you haveclickhouse-driverinstalled. In most cases this leads to a nicer out-of-the-box experience, but in this case the integration doesn't work properly withdjango-clickhouse-backendbecause it starts queries slightly differently compared to vanillaclickhouse-driver.In other words, the reason it seemed to work in 1.45.0 is most likely because the integration was not enabled. @marsha97 Correct me if I'm wrong -- you weren't explicitly enabling the integration via
integrations=[ClickhouseDriverIntegration()], right?Fixing this in #3096 to restore previous behavior (i.e., the integration not actually doing much when used with
django-clickhouse-backend). Will roll a release with this tomorrow latest. If anyone needs a workaround until then, you can disable auto enabling integrations and enable the ones you need explicitly.We will follow up to actually make this work properly in #3095 (this might take a bit).
marsha97 commentedon May 22, 2024
Yes, correct, i didn't specify the ch integration explicitly
sentrivana commentedon May 23, 2024
The fix for this will be out in 2.3.0 later today.