(
        self,
        key_prefix: str,
        metric_query: str,
        metric_type: str,
        time_start: int,
        time_end: int,
        is_regex: bool = False,
        extra_dimensions: Optional[Dict[str, str]] = None,
    )
return new_data
Query the backend datastore to get any new metrics values

        Override this method in any subclasses to take advantage of pre-/post-processing of the return value,
        as well as the metrics cache.

        Arguments/return value are the same as for `get_metrics_values`
Query the backend datastore to get any new metrics values
Query the backend datastore to get any new metrics values
def _get_new_metric_values(
        self,
        key_prefix: str,
        metric_query: str,
        metric_type: str,
        time_start: int,
        time_end: int,
        is_regex: bool = False,
        extra_dimensions: Optional[Dict[str, str]] = None,
    ) -> MetricsValuesDict:
        """
        Query the backend datastore to get any new metrics values

        Override this method in any subclasses to take advantage of pre-/post-processing of the return value,
        as well as the metrics cache.

        Arguments/return value are the same as for `get_metrics_values`
        """
        logger.info(
            "Querying datastore for {key} between {start} and {end} (is_regex={is_regex})".format(
                key=metric_query, start=time_start, end=time_end, is_regex=is_regex,
            )
        )
        new_data: MetricsValuesDict = defaultdict(list)
        table_name = self._get_table_name(metric_type)
        table = self.ddb.Table(table_name)

        if is_regex:
            metric_keys = self._get_keys_from_query(key_prefix, metric_query, time_start, time_end, table)
        else:
            metric_keys = {key_prefix + metric_query}
        time_start = convert_decimal(time_start)
        time_end = convert_decimal(time_end)

        # keys come back from self._get_keys_from_query with key_prefix prepended so we don't have to do it here
        for metric_key in metric_keys:
            full_query_key = generate_key_with_dimensions(metric_key, extra_dimensions)
            query_condition = Key("key").eq(full_query_key) & Key("timestamp").between(time_start, time_end)
            response = table.query(KeyConditionExpression=query_condition)

            new_data[metric_key] = self._extract_timestamp_and_value_from_items(response["Items"])

            # Results are possibly paginated if too large.
            while response.get("LastEvaluatedKey") is not None:
                response = table.query(
                    ExclusiveStartKey=response.get("LastEvaluatedKey"), KeyConditionExpression=query_condition,
                )
                new_data[metric_key].extend(self._extract_timestamp_and_value_from_items(response["Items"]))

        return new_data
def _get_new_metric_values ( self , key_prefix : str , metric_query : str , metric_type : str , time_start : int , time_end : int , is_regex : bool = False , extra_dimensions : Optional [ Dict [ str , str ] ] = None , ) -> MetricsValuesDict : logger . info ( "Querying datastore for {key} between {start} and {end} (is_regex={is_regex})" . format ( key = metric_query , start = time_start , end = time_end , is_regex = is_regex , ) ) new_data : MetricsValuesDict = defaultdict ( list ) table_name = self . _get_table_name ( metric_type ) table = self . ddb . Table ( table_name ) if is_regex : metric_keys = self . _get_keys_from_query ( key_prefix , metric_query , time_start , time_end , table ) else : metric_keys = { key_prefix + metric_query } time_start = convert_decimal ( time_start ) time_end = convert_decimal ( time_end ) # keys come back from self._get_keys_from_query with key_prefix prepended so we don't have to do it here for metric_key in metric_keys : full_query_key = generate_key_with_dimensions ( metric_key , extra_dimensions ) query_condition = Key ( "key" ) . eq ( full_query_key ) & Key ( "timestamp" ) . between ( time_start , time_end ) response = table . query ( KeyConditionExpression = query_condition ) new_data [ metric_key ] = self . _extract_timestamp_and_value_from_items ( response [ "Items" ] ) # Results are possibly paginated if too large. while response . get ( "LastEvaluatedKey" ) is not None : response = table . query ( ExclusiveStartKey = response . get ( "LastEvaluatedKey" ) , KeyConditionExpression = query_condition , ) new_data [ metric_key ] . extend ( self . _extract_timestamp_and_value_from_items ( response [ "Items" ] ) ) return new_data