diff --git a/src/django_clickhouse/database.py b/src/django_clickhouse/database.py index 1c44b08..8068d42 100644 --- a/src/django_clickhouse/database.py +++ b/src/django_clickhouse/database.py @@ -1,5 +1,5 @@ -from infi.clickhouse_orm.database import Database as InfiDatabase, ServerError -from infi.clickhouse_orm.migrations import MigrationHistory +from infi.clickhouse_orm.database import Database as InfiDatabase +from statsd.defaults.django import statsd from .configuration import config from .exceptions import DBAliasError @@ -26,6 +26,11 @@ class Database(InfiDatabase): def _get_applied_migrations(self, migrations_package_name): raise NotImplementedError("This method is not supported by django_clickhouse.") + def _send(self, data, settings=None, stream=False): + statsd_key = "%s.query" % (config.STATSD_PREFIX) + with statsd.timer(statsd_key): + return super(Database, self)._send(data, settings=settings, stream=stream) + class ConnectionProxy: _connections = {} diff --git a/src/django_clickhouse/models.py b/src/django_clickhouse/models.py index 9da320b..61eaf95 100644 --- a/src/django_clickhouse/models.py +++ b/src/django_clickhouse/models.py @@ -9,7 +9,7 @@ import six from django.db import transaction from django.db.models.signals import post_save, post_delete from django.dispatch import receiver -from django.db.models import QuerySet as DjangoQuerySet, Manager as DjangoManager, Model as DjangoModel +from django.db.models import QuesrySet as DjangoQuerySet, Manager as DjangoManager, Model as DjangoModel from .configuration import config from .storages import Storage