original_docstring:  Fetch a read/write capacity metric 
docstring: Fetch a read/write capacity metric
docstring_tokens: Fetch a read / write capacity metric
code: def _get_metric(self, metric, tablename, index_name=None):
          """ Fetch a read/write capacity metric """
          end = time.time()
          begin = end - 3 * 60  # 3 minute window
          dimensions = [{"Name": "TableName", "Value": tablename}]
          if index_name is not None:
              dimensions.append({"Name": "GlobalSecondaryIndexName", "Value": index_name})
          period = 60
          data = self.cloudwatch_connection.get_metric_statistics(
              Period=period,
              StartTime=begin,
              EndTime=end,
              MetricName=metric,
              Namespace="AWS/DynamoDB",
              Statistics=["Sum"],
              Dimensions=dimensions,
          )
          points = data["Datapoints"]
          if not points:
              return 0
          else:
              points.sort(key=lambda r: r["Timestamp"])
              return float(points[-1]["Sum"]) / period
code_tokens: def _get_metric ( self , metric , tablename , index_name = None ) : end = time . time ( ) begin = end - 3 * 60 dimensions = [ { "Name" : "TableName" , "Value" : tablename } ] if index_name is not None : dimensions . append ( { "Name" : "GlobalSecondaryIndexName" , "Value" : index_name } ) period = 60 data = self . cloudwatch_connection . get_metric_statistics ( Period = period , StartTime = begin , EndTime = end , MetricName = metric , Namespace = "AWS/DynamoDB" , Statistics = [ "Sum" ] , Dimensions = dimensions , ) points = data [ "Datapoints" ] if not points : return 0 else : points . sort ( key = lambda r : r [ "Timestamp" ] ) return float ( points [ - 1 ] [ "Sum" ] ) / period
short_docstring: Fetch a read/write capacity metric
short_docstring_tokens: Fetch a read / write capacity metric
comment: """ Fetch a read/write capacity metric """$SEP$# 3 minute window