From e8a15e43308dad2a42cf61667ed56f8e1b2cd193 Mon Sep 17 00:00:00 2001 From: M1ha Date: Wed, 19 Dec 2018 16:15:17 +0500 Subject: [PATCH] Fixed statsd counters --- src/django_clickhouse/clickhouse_models.py | 8 ++++---- src/django_clickhouse/storages.py | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/django_clickhouse/clickhouse_models.py b/src/django_clickhouse/clickhouse_models.py index 9e9ac78..6e87214 100644 --- a/src/django_clickhouse/clickhouse_models.py +++ b/src/django_clickhouse/clickhouse_models.py @@ -199,7 +199,7 @@ class ClickHouseModel(with_metaclass(ClickHouseModelMeta, InfiModel)): with statsd.timer(statsd_key.format('steps.get_operations')): operations = storage.get_operations(import_key, cls.get_sync_batch_size()) - statsd.incr(statsd_key.format('operations', len(operations))) + statsd.incr(statsd_key.format('operations'), len(operations)) if operations: with statsd.timer(statsd_key.format('steps.get_sync_objects')): @@ -207,7 +207,7 @@ class ClickHouseModel(with_metaclass(ClickHouseModelMeta, InfiModel)): else: import_objects = [] - statsd.incr(statsd_key.format('import_objects', len(import_objects))) + statsd.incr(statsd_key.format('import_objects'), len(import_objects)) if import_objects: with statsd.timer(statsd_key.format('steps.get_insert_batch')): @@ -264,7 +264,7 @@ class ClickHouseMultiModel(ClickHouseModel): with statsd.timer(statsd_key.format('steps.get_operations')): operations = storage.get_operations(import_key, cls.get_sync_batch_size()) - statsd.incr(statsd_key.format('operations', len(operations))) + statsd.incr(statsd_key.format('operations'), len(operations)) if operations: with statsd.timer(statsd_key.format('steps.get_sync_objects')): @@ -272,7 +272,7 @@ class ClickHouseMultiModel(ClickHouseModel): else: import_objects = [] - statsd.incr(statsd_key.format('import_objects', len(import_objects))) + statsd.incr(statsd_key.format('import_objects'), len(import_objects)) if import_objects: batches = {} diff --git a/src/django_clickhouse/storages.py b/src/django_clickhouse/storages.py index 799df7d..50eaba4 100644 --- a/src/django_clickhouse/storages.py +++ b/src/django_clickhouse/storages.py @@ -117,6 +117,7 @@ class Storage: % (operation, len(pks), import_key)) statsd_key = "%s.sync.%s.register_operations" % (config.STATSD_PREFIX, import_key) + statsd.incr(statsd_key + '.%s' % operation, len(pks)) with statsd.timer(statsd_key): return self.register_operations(import_key, operation, *pks)