Fixed statsd counters

This commit is contained in:
M1ha 2018-12-19 16:15:17 +05:00
parent 6a1ffbadd3
commit e8a15e4330
2 changed files with 5 additions and 4 deletions

View File

@ -199,7 +199,7 @@ class ClickHouseModel(with_metaclass(ClickHouseModelMeta, InfiModel)):
with statsd.timer(statsd_key.format('steps.get_operations')): with statsd.timer(statsd_key.format('steps.get_operations')):
operations = storage.get_operations(import_key, cls.get_sync_batch_size()) 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: if operations:
with statsd.timer(statsd_key.format('steps.get_sync_objects')): with statsd.timer(statsd_key.format('steps.get_sync_objects')):
@ -207,7 +207,7 @@ class ClickHouseModel(with_metaclass(ClickHouseModelMeta, InfiModel)):
else: else:
import_objects = [] 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: if import_objects:
with statsd.timer(statsd_key.format('steps.get_insert_batch')): 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')): with statsd.timer(statsd_key.format('steps.get_operations')):
operations = storage.get_operations(import_key, cls.get_sync_batch_size()) 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: if operations:
with statsd.timer(statsd_key.format('steps.get_sync_objects')): with statsd.timer(statsd_key.format('steps.get_sync_objects')):
@ -272,7 +272,7 @@ class ClickHouseMultiModel(ClickHouseModel):
else: else:
import_objects = [] 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: if import_objects:
batches = {} batches = {}

View File

@ -117,6 +117,7 @@ class Storage:
% (operation, len(pks), import_key)) % (operation, len(pks), import_key))
statsd_key = "%s.sync.%s.register_operations" % (config.STATSD_PREFIX, 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): with statsd.timer(statsd_key):
return self.register_operations(import_key, operation, *pks) return self.register_operations(import_key, operation, *pks)