Exemplo n.º 1
0
    def show_all_metrics(self):
        if self.__is_zipkin:
            start_time = time.time()

            start_timestamp = my_time.to_unix_time_millis(
                self.__start_date_time_str)
            end_timestamp = my_time.to_unix_time_millis(
                self.__end_date_time_str)

            self.view.display_time(
                'start_time:',
                my_time.from_timestamp_to_datetime(start_timestamp),
                start_timestamp)
            self.view.display_time(
                'end_time:', my_time.from_timestamp_to_datetime(end_timestamp),
                end_timestamp)

            timestamps = my_time.timestamp_millis_split(
                start_timestamp, end_timestamp)

            service_names = zipkin.get_services()

            timestamps = my_list.tuple_list(timestamps)

            print(len(timestamps))

            for timestamp_tuple in timestamps:
                cl.process_all_metrics_in_time(service_names,
                                               timestamp_tuple[0],
                                               timestamp_tuple[1])

            self.view.display_message(
                'Time processing',
                'finish in {} seconds'.format(time.time() - start_time))
Exemplo n.º 2
0
    def show_response_time_analysis(self):
        if self.__is_zipkin:
            start_time = time.time()

            start_timestamp = my_time.to_unix_time_millis(
                self.__start_date_time_str)
            end_timestamp = my_time.to_unix_time_millis(
                self.__end_date_time_str)

            service_names = zipkin.get_services()

            timestamps = my_time.timestamp_millis_split(
                start_timestamp, end_timestamp)
            timestamps = my_list.tuple_list(timestamps)

            for timestamp_1, timestamp_2 in timestamps:
                # TODO: IMPROVE DATA USAGE.
                for service_name in service_names:
                    traces = zipkin.get_traces(service_name=service_name,
                                               end_ts=end_timestamp,
                                               lookback=end_timestamp -
                                               start_timestamp)

                    span_trees = my_trace.generate_span_trees(traces)
                    trace_metrics_data = my_trace.extract_metrics(span_trees)

                    message = cl.service_response_time_analysis(
                        service_name, trace_metrics_data, timestamp_1,
                        timestamp_2)
                    self.view.display_message(message[0], message[1])

            self.view.display_message(
                'Time processing',
                'finish in {} seconds'.format(time.time() - start_time))
Exemplo n.º 3
0
    def show_morphology_analysis_in_time(self):
        if self.__is_zipkin:
            start_time = time.time()

            start_timestamp = my_time.to_unix_time_millis(
                self.__start_date_time_str)
            end_timestamp = my_time.to_unix_time_millis(
                self.__end_date_time_str)

            self.view.display_time(
                'start_time:',
                my_time.from_timestamp_to_datetime(start_timestamp),
                start_timestamp)
            self.view.display_time(
                'end_time:', my_time.from_timestamp_to_datetime(end_timestamp),
                end_timestamp)

            timestamps = my_time.timestamp_millis_split(
                start_timestamp, end_timestamp)
            timestamps = my_list.tuple_list(timestamps)

            for timestamp_1, timestamp_2 in timestamps:
                dependencies = zipkin.get_dependencies(end_ts=timestamp_2,
                                                       lookback=timestamp_2 -
                                                       timestamp_1)

                message = cl.service_morphology(dependencies, timestamp_1,
                                                timestamp_2)
                self.view.display_message(message[0], message[1])

            self.view.display_message(
                'Time processing',
                'finish in {} seconds'.format(time.time() - start_time))
Exemplo n.º 4
0
    def show_service_status_code_analysis_in_time(self):
        if self.__is_zipkin:
            start_time = time.time()

            start_timestamp = my_time.to_unix_time_millis(
                self.__start_date_time_str)
            end_timestamp = my_time.to_unix_time_millis(
                self.__end_date_time_str)

            self.view.display_time(
                'start_time:',
                my_time.from_timestamp_to_datetime(start_timestamp),
                start_timestamp)
            self.view.display_time(
                'end_time:', my_time.from_timestamp_to_datetime(end_timestamp),
                end_timestamp)

            service_names = zipkin.get_services()

            timestamps = my_time.timestamp_millis_split(
                start_timestamp, end_timestamp)
            timestamps = my_list.tuple_list(timestamps)

            for timestamp_1, timestamp_2 in timestamps:
                for service_name in service_names:
                    traces = zipkin.get_traces(service_name=service_name,
                                               end_ts=end_timestamp,
                                               lookback=end_timestamp -
                                               start_timestamp)

                    message = cl.service_status_codes(service_name, traces,
                                                      timestamp_1, timestamp_2)
                    self.view.display_message(message[0], message[1])

            self.view.display_message(
                'Time processing',
                'finish in {} seconds'.format(time.time() - start_time))
Exemplo n.º 5
0
 def test_timestamp_millis_split(self):
     """ Test timestamp_millis_split function. """
     self.assertEqual(my_time.timestamp_millis_split(self.__unix_timestamp_millis, self.__unix_timestamp_millis_2),
                      [self.__unix_timestamp_millis, self.__unix_timestamp_millis_2])