Added query time statsd timer

This commit is contained in:
M1ha 2019-01-23 10:32:11 +05:00
parent 780b13a42e
commit 882930a3a8
2 changed files with 8 additions and 3 deletions

View File

@ -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 = {}

View File

@ -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