Beispiel #1
0
    def get_state(self, duration):
        '''Run any necessary calculations on the data collected from the logs
        and return a list of metric objects.'''

        if len(self.waits) > 0:
            return [
                MetricObject("wait.min", min(self.waits)),
                MetricObject("wait.max", max(self.waits)),
                MetricObject("wait.mean", stats_helper.find_mean(self.waits)),
                MetricObject("wait.median", stats_helper.find_median(self.waits)),
                MetricObject("wait.90th_percentile", stats_helper.find_percentile(self.waits, 90)),
                MetricObject("wait.95th_percentile", stats_helper.find_percentile(self.waits, 95)),

                MetricObject("connect.min", min(self.connects)),
                MetricObject("connect.max", max(self.connects)),
                MetricObject("connect.mean", stats_helper.find_mean(self.connects)),
                MetricObject("connect.median", stats_helper.find_median(self.connects)),
                MetricObject("connect.90th_percentile", stats_helper.find_percentile(self.connects, 90)),
                MetricObject("connect.95th_percentile", stats_helper.find_percentile(self.connects, 95)),

                MetricObject("service.min", min(self.services)),
                MetricObject("service.max", max(self.services)),
                MetricObject("service.mean", stats_helper.find_mean(self.services)),
                MetricObject("service.median", stats_helper.find_median(self.services)),
                MetricObject("service.90th_percentile", stats_helper.find_percentile(self.services, 90)),
                MetricObject("service.95th_percentile", stats_helper.find_percentile(self.services, 95))
                ]
        else:
            return []
    def get_state(self, duration):
        '''Run any necessary calculations on the data collected from the logs
        and return a list of metric objects.'''

        self.duration = duration
        metrics = []

        # loop all the collected timers
        for time_name in self.times:
            values = self.times[time_name]['values']
            unit = self.times[time_name]['unit']
            # add counter
            if self.duration > 0:
                metrics.append(
                    MetricObject(time_name + '.count',
                                 len(values) / self.duration))
            # calculate statistical values
            metrics.append(
                MetricObject(time_name + '.mean',
                             stats_helper.find_mean(values), unit))
            metrics.append(
                MetricObject(time_name + '.median',
                             stats_helper.find_median(values), unit))
            metrics += [
                MetricObject(
                    '%s.%sth_percentile' % (time_name, percentile),
                    stats_helper.find_percentile(values, int(percentile)),
                    unit) for percentile in self.percentiles
            ]

        return metrics
Beispiel #3
0
    def get_state(self, duration):
        '''Run any necessary calculations on the data collected from the logs
        and return a list of metric objects.'''
        duration = float(duration)
        metrics = []
        if duration > 0 and not self.raw_data:
            metrics += [
                MetricObject(counter, self.counts[counter] / duration)
                for counter in self.counts
            ]
        elif self.raw_data:
            metrics += [
                MetricObject(counter, self.counts[counter])
                for counter in self.counts
            ]
        for time_name in self.times:
            values = self.times[time_name]['values']
            unit = self.times[time_name]['unit']
            metrics.append(
                MetricObject(time_name + '.mean',
                             stats_helper.find_mean(values), unit))
            metrics.append(
                MetricObject(time_name + '.median',
                             stats_helper.find_median(values), unit))
            metrics += [
                MetricObject(
                    '%s.%sth_percentile' % (time_name, percentile),
                    stats_helper.find_percentile(values, int(percentile)),
                    unit) for percentile in self.percentiles
            ]

        return metrics
Beispiel #4
0
    def get_state(self, duration):
        '''Run any necessary calculations on the data collected from the logs
        and return a list of metric objects.'''
        metrics = []
        if duration > 0:
            metrics += [MetricObject(counter, self.counts[counter]/duration) for counter in self.counts]
        for time_name in self.times:
            values = self.times[time_name]['values']
            unit = self.times[time_name]['unit']
            metrics.append(MetricObject(time_name+'.mean', stats_helper.find_mean(values), unit))
            metrics.append(MetricObject(time_name+'.median', stats_helper.find_median(values), unit))
            metrics += [MetricObject('%s.%sth_percentile' % (time_name,percentile), stats_helper.find_percentile(values,int(percentile)), unit) for percentile in self.percentiles]

        return metrics