Ejemplo n.º 1
0
def normalize_date_range_params(args, report_start_date):
    '''
    Normalizes date range used for Data collection.
    Start date for Data collection could be args.start_date, reportStartDate or yesterday
    End data for Data collection could be args.stop_date or yesterday
    :param args: List of arguments provided through CLI
    :param report_start_date: reportStartDate specified in telemetry.conf
    :return:
    '''
    yesterday = datetime.date.today() - datetime.timedelta(days=1)

    args.start_date = datetime_util.str_to_date(args.start_date) if args.start_date\
        else datetime_util.str_to_date(report_start_date) if report_start_date else yesterday

    args.stop_date = datetime_util.str_to_date(args.stop_date) if args.stop_date else yesterday
Ejemplo n.º 2
0
    def data_point_results_transform(self, class_def, data_point_result,
                                     date_range):
        fields = class_def.index_fields
        hash_key = class_def.getHashKey()

        result = {"data": None}
        if data_point_result['data']:
            if (isinstance(data_point_result['data'], basestring)):
                data = json.loads(data_point_result['data'])
            else:
                data = data_point_result['data']

            data = hash_specific_value_by_key(data=data,
                                              hash_key=hash_key,
                                              scheme=self.scheme)
            data = transform_object(data=data, fields=fields)
            result['data'] = data

        result['timestamp'] = date_to_timestamp(utcNow())

        result['component'] = class_def.component
        result['date'] = date_range['stop'].isoformat()

        data_point_time = data_point_result.get('_time')

        if not date_range['stop'] == date_range['start']:
            try:
                if data_point_result.get('date'):
                    result['date'] = data_point_result.get('date')
                elif data_point_time and 'T' in data_point_time:
                    result['date'] = data_point_result.get('_time').split(
                        'T')[0]
            except Exception:
                result['date'] = date_range['stop'].isoformat()

        # SPECIAL CASE:
        # At least one (the indexer cluster member count) data point is retrieved
        # on the fly during data collection. Its time/date will be "today" though
        # it really pertains to the stop date (typically yesterday in prod).
        # Note - There is discussion of having each node persist this data so the
        #        true historical values can be retrieved later. That would eliminate
        #        this situation.
        if str_to_date(result['date']) > date_range['stop']:
            result['date'] = date_range['stop']

        result['visibility'] = class_def.visibility or "anonymous"
        result['executionID'] = INST_EXECUTION_ID

        return result
Ejemplo n.º 3
0
def normalize_date_range_params(args):
    yesterday = datetime.date.today() - datetime.timedelta(days=1)
    args.start_date = datetime_util.str_to_date(
        args.start_date) if args.start_date else yesterday
    args.stop_date = datetime_util.str_to_date(
        args.stop_date) if args.stop_date else yesterday