예제 #1
0
 def process_request(self, request):
     if self.should_track_request(request) and is_sampling_request():
         self.tracking = True
         self.start_time = time.time()
         self.rm = get_instance('requests')
     else:
         self.tracking = False
예제 #2
0
 def execute(self, sql, params=()):
     if is_sampling_request():
         start = time.time()
         self.rm = get_instance('sqlops')
         try:
             return self.cursor.execute(sql, params)
         finally:
             stop = time.time()
             duration_in_microseconds = int(1000000 * (stop - start))
             try:
                 self.rm.record_hit_with_weight(duration_in_microseconds)
             except Exception, e:
                 pass #logging.warn('RedisMonitor error: %s' % str(e))