예제 #1
0
    def slow_sql_data(self):
        """
        :return:
        """
        if not self.__slow_sql_packets:
            return []

        result = {"type": "sqlTraceData", "sqlTraces": []}
        maximum = self.__settings.slow_sql_count
        slow_sql_nodes = sorted(six.itervalues(self.__slow_sql_packets), key=lambda x: x.max_call_time)[-maximum:]

        for node in slow_sql_nodes:
            explain_plan = node.slow_sql_node.explain_plan
            params = {"explainPlan": explain_plan if explain_plan else {}, "stacktrace": []}

            if node.slow_sql_node.stack_trace:
                for line in node.slow_sql_node.stack_trace:
                    line = [line.filename, line.lineno, line.name, line.locals]
                    if len(line) >= 4 and 'tingyun' not in line[0]:
                        params['stacktrace'].append("%s(%s:%s)" % (line[2], line[0], line[1]))

            result['sqlTraces'].append([node.slow_sql_node.start_time, node.slow_sql_node.path,
                                        node.slow_sql_node.metric, node.slow_sql_node.request_uri,
                                        node.slow_sql_node.formatted, node.call_count,
                                        node.total_call_time, node.max_call_time,
                                        node.min_call_time, str(params)])

        self.__slow_sql_packets = {}
        return result
예제 #2
0
파일: packager.py 프로젝트: xuning992/tfty
    def external_error_data(self):
        rtv = [
            error["item"]
            for error in six.itervalues(self.__traced_external_errors)
        ]
        self.__traced_external_errors = {}

        return rtv
예제 #3
0
    def error_trace_data(self):
        """
        :return:
        """
        rtv = [error["item"] for error in six.itervalues(self.__traced_errors)]
        self.__traced_errors = {}

        return rtv
예제 #4
0
    def exception_trace_data(self):
        """
        :return:
        """
        rtv = [ex["item"] for ex in six.itervalues(self.__traced_exception)]
        self.__traced_errors = {}

        return rtv
예제 #5
0
    def action_trace_data(self):
        """
        :return:
        """
        if not self.__slow_action:
            return []

        trace_data = []

        for traces in six.itervalues(self.__slow_action):
            for trace in traces:
                trace_data.append(trace[0])

        return {"type": "actionTraceData", "actionTraces": trace_data}