Ejemplo n.º 1
0
        def wrapper(*args, **kwargs):
            start = time.time()
            try:
                results = fun(*args, **kwargs)
            except Exception as e:
                raise e
            end = time.time()

            request = hacks.find_request()

            if request:
                if not hasattr(request, '_sql_query_times'):
                    request._sql_query_times = []

                request._sql_query_times.append((end-start) * 1000)

                if (hasattr(request, '_cached_user')
                        and hasattr(request._cached_user, 'username')
                        and request._cached_user.username == 'sqltest'
                        and request.path_info not in [
                            '/api/metric/record',
                        ]):
                    util.papertrail.info(u'SQLtest: [{:.2f} - {}] {}'.format((end-start) * 1000, request.path_info, args))

                    #if "SELECT `auth_user`.`id`," in args.__repr__():
                    #    stk = traceback.extract_stack()
                    #    for mod, lineno, fun_name, call_code_text in stk:
                    #        util.papertrail.debug("[%s:%i] in %s" % (mod, lineno, fun_name))
                    #        util.papertrail.debug('-')

            return results
    def record_command(self, tdelta, command, result_size):
        if settings.DEBUG:

            self.commands.append((self._host, self._port, self._db, tdelta, traceback.extract_stack(), command, result_size))

        request = hacks.find_request()

        if request:
            if not hasattr(request, "_redis_commands"):
                request._redis_commands = []

            request._redis_commands.append(tdelta)
Ejemplo n.º 3
0
        def wrapper(*args, **kwargs):
            start = time.time()
            results = fun(*args, **kwargs)
            end = time.time()

            request = hacks.find_request()

            if request:
                if not hasattr(request, "_sql_queries"):
                    request._sql_queries = []

                request._sql_queries.append((end-start) * 1000)

            return results
Ejemplo n.º 4
0
    def record_command(self, tdelta, command, result_size):
        if settings.DEBUG:

            self.commands.append(
                (self._host, self._port, self._db, tdelta,
                 traceback.extract_stack(), command, result_size))

        request = hacks.find_request()

        if request:
            if not hasattr(request, "_redis_commands"):
                request._redis_commands = []

            request._redis_commands.append(tdelta)