lib/rhosync/source_sync.rb in rhosync-2.0.8 vs lib/rhosync/source_sync.rb in rhosync-2.0.9

- old
+ new

@@ -9,19 +9,19 @@ @adapter = SourceAdapter.create(@source) end # CUD Operations def create(client_id) - _process_cud('create',client_id) + _measure_and_process_cud('create',client_id) end def update(client_id) - _process_cud('update',client_id) + _measure_and_process_cud('update',client_id) end def delete(client_id) - _process_cud('delete',client_id) + _measure_and_process_cud('delete',client_id) end # Read Operation; params are query arguments def read(client_id=nil,params=nil) _read('query',client_id,params) @@ -58,13 +58,15 @@ end end def do_query(params=nil) @source.if_need_refresh do - return if _auth_op('login') == false - self.read(nil,params) - _auth_op('logoff') + Stats::Record.update("source:query:#{@source.name}") do + return if _auth_op('login') == false + self.read(nil,params) + _auth_op('logoff') + end end end # Enqueue a job for the source based on job type def async(job_type,queue_name,client_id=nil,params=nil) @@ -139,9 +141,15 @@ value['id'] = key # Perform operation @adapter.delete value dels ||= {} dels[key] = value + end + + def _measure_and_process_cud(operation,client_id) + Stats::Record.update("source:#{operation}:#{@source.name}") do + _process_cud(operation,client_id) + end end def _process_cud(operation,client_id) errors,links,deletes,creates,dels = {},{},{},{},{} client = Client.load(client_id,{:source_name => @source.name})