Return current value for the metric
546269
def value(self):
        
        if self.buffer:
            return np.mean([ep['l'] for ep in self.buffer])
        else:
            return 0
84066
private double getMetricAverageValue(final String metricName) {
        int min = 0;
        int max = 1;

        if (metricName.equals(Constants.CPU_UTILIZATION)) {
            min = Integer.parseInt(PropertiesUtils
                    .getProperty(Constants.CPU_UTILIZATION_RANGE_AVERAGE).split(",")[0]);
            max = Integer.parseInt(PropertiesUtils
                    .getProperty(Constants.CPU_UTILIZATION_RANGE_AVERAGE).split(",")[1]);
        } else if (metricName.equals(Constants.DISK_READ_BYTES)) {
            min = Integer.parseInt(PropertiesUtils
                    .getProperty(Constants.DISK_READ_BYTES_RANGE_AVERAGE).split(",")[0]);
            max = Integer.parseInt(PropertiesUtils
                    .getProperty(Constants.DISK_READ_BYTES_RANGE_AVERAGE).split(",")[1]);
        } else if (metricName.equals(Constants.DISK_READ_OPS)) {
            min = Integer.parseInt(PropertiesUtils
                    .getProperty(Constants.DISK_READ_OPS_RANGE_AVERAGE).split(",")[0]);
            max = Integer.parseInt(PropertiesUtils
                    .getProperty(Constants.DISK_READ_OPS_RANGE_AVERAGE).split(",")[1]);
        } else if (metricName.equals(Constants.DISK_WRITE_BYTES)) {
            min = Integer.parseInt(PropertiesUtils
                    .getProperty(Constants.DISK_WRITE_BYTES_RANGE_AVERAGE).split(",")[0]);
            max = Integer.parseInt(PropertiesUtils
                    .getProperty(Constants.DISK_WRITE_BYTES_RANGE_AVERAGE).split(",")[1]);
        } else if (metricName.equals(Constants.DISK_WRITE_OPS)) {
            min = Integer.parseInt(PropertiesUtils
                    .getProperty(Constants.DISK_WRITE_OPS_RANGE_AVERAGE).split(",")[0]);
            max = Integer.parseInt(PropertiesUtils
                    .getProperty(Constants.DISK_WRITE_OPS_RANGE_AVERAGE).split(",")[1]);
        } else if (metricName.equals(Constants.NETWORK_IN)) {
            min = Integer.parseInt(
                    PropertiesUtils.getProperty(Constants.NETWORK_IN_RANGE_AVERAGE).split(",")[0]);
            max = Integer.parseInt(
                    PropertiesUtils.getProperty(Constants.NETWORK_IN_RANGE_AVERAGE).split(",")[1]);
        } else if (metricName.equals(Constants.NETWORK_OUT)) {
            min = Integer.parseInt(
                    PropertiesUtils.getProperty(Constants.NETWORK_OUT_RANGE_AVERAGE).split(",")[0]);
            max = Integer.parseInt(
                    PropertiesUtils.getProperty(Constants.NETWORK_OUT_RANGE_AVERAGE).split(",")[1]);
        } else if (metricName.equals(Constants.NETWORK_PACKETS_IN)) {
            min = Integer.parseInt(PropertiesUtils
                    .getProperty(Constants.NETWORK_PACKETS_IN_RANGE_AVERAGE).split(",")[0]);
            max = Integer
                    .parseInt(PropertiesUtils
                            .getProperty(Constants.NETWORK_PACKETS_IN_RANGE_AVERAGE).split(",")[1]);
        } else if (metricName.equals(Constants.NETWORK_PACKETS_OUT)) {
            min = Integer
                    .parseInt(
                            PropertiesUtils.getProperty(Constants.NETWORK_PACKETS_OUT_RANGE_AVERAGE)
                                    .split(",")[0]);
            max = Integer
                    .parseInt(
                            PropertiesUtils.getProperty(Constants.NETWORK_PACKETS_OUT_RANGE_AVERAGE)
                                    .split(",")[1]);
        } else if (metricName.equals(Constants.STATUS_CHECK_FAILED)) {
            min = Integer
                    .parseInt(
                            PropertiesUtils.getProperty(Constants.STATUS_CHECK_FAILED_RANGE_AVERAGE)
                                    .split(",")[0]);
            max = Integer
                    .parseInt(
                            PropertiesUtils.getProperty(Constants.STATUS_CHECK_FAILED_RANGE_AVERAGE)
                                    .split(",")[1]);
        } else if (metricName.equals(Constants.STATUS_CHECK_FAILED_INSTANCE)) {
            min = Integer.parseInt(
                    PropertiesUtils
                            .getProperty(Constants.STATUS_CHECK_FAILED_INSTANCE_RANGE_AVERAGE)
                            .split(",")[0]);
            max = Integer.parseInt(
                    PropertiesUtils
                            .getProperty(Constants.STATUS_CHECK_FAILED_INSTANCE_RANGE_AVERAGE)
                            .split(",")[1]);
        } else if (metricName.equals(Constants.STATUS_CHECK_FAILED_SYSTEM)) {
            min = Integer.parseInt(
                    PropertiesUtils.getProperty(Constants.STATUS_CHECK_FAILED_SYSTEM_RANGE_AVERAGE)
                            .split(",")[0]);
            max = Integer.parseInt(
                    PropertiesUtils.getProperty(Constants.STATUS_CHECK_FAILED_SYSTEM_RANGE_AVERAGE)
                            .split(",")[1]);
        } else if (metricName.equals(Constants.CPU_CREDIT_USAGE)) {
            min = Integer.parseInt(PropertiesUtils
                    .getProperty(Constants.CPU_CREDIT_USAGE_RANGE_AVERAGE).split(",")[0]);
            max = Integer.parseInt(PropertiesUtils
                    .getProperty(Constants.CPU_CREDIT_USAGE_RANGE_AVERAGE).split(",")[1]);
        } else if (metricName.equals(Constants.ESTIMATED_CHARGES)) {
            min = Integer.parseInt(PropertiesUtils
                    .getProperty(Constants.ESTIMATED_CHARGES_RANGE_AVERAGE).split(",")[0]);
            max = Integer.parseInt(PropertiesUtils
                    .getProperty(Constants.ESTIMATED_CHARGES_RANGE_AVERAGE).split(",")[1]);
        } else if (metricName.equals(Constants.CPU_CREDIT_BALANCE)) {
            min = Integer
                    .parseInt(PropertiesUtils
                            .getProperty(Constants.CPU_CREDIT_BALANCE_RANGE_AVERAGE).split(",")[0]);
            max = Integer
                    .parseInt(PropertiesUtils
                            .getProperty(Constants.CPU_CREDIT_BALANCE_RANGE_AVERAGE).split(",")[1]);
        }

        return new Random().nextInt((max - min) + 1) + min;
    }
294572
def _process_metric(self, data, metric, xtype, path, xform=None, tags=None, hostname=None):
        
        value = data

        # Traverse the nested dictionaries
        for key in path.split('.'):
            if value is not None:
                value = value.get(key)
            else:
                break

        if value is not None:
            if xform:
                value = xform(value)
            if xtype == "gauge":
                self.gauge(metric, value, tags=tags, hostname=hostname)
            else:
                self.rate(metric, value, tags=tags, hostname=hostname)
        else:
            self.log.debug("Metric not found: %s -> %s", path, metric)
49394
async def get_metrics(self):
        
        metrics = await self.model.get_metrics(self.tag)
        return metrics[self.name]
695380
def metric(slug, num=1, category=None, expire=None, date=None):
    """"""
    get_r().metric(slug, num=num, category=category, expire=expire, date=date)
216786
private String getFormattedValue(MetricValue metricValue) {
    if (metricValue.hasDoubleValue()) {
      return DECIMAL_FORMAT.format(metricValue.getDoubleValue());
    } else {
      return DECIMAL_FORMAT.format(metricValue.getLongValue());
    }
  }
1230826
def set_metric(slug, value, category=None, expire=None, date=None):
    """"""
    get_r().set_metric(slug, value, category=category, expire=expire, date=date)
738543
def intermediate_value(self, metric):
        
        if ':' in metric:
            metric_name = metric.split(':')[-1]
        else:
            metric_name = metric

        return self.metrics_by_name[metric_name].value()
1353570
def value(self, value):
        
        args = (self.__ptr, int(value))
        _ec.metric_set(args)
1271133
def metric_streaming(self):
        
        if not self.__metric_streaming:
            self.__metric_streaming = MetricStreaming(self.__connection)
        return self.__metric_streaming
1081155
public Object getMetric(String key) throws MetricsException {
		MetricsKey mk = new MetricsKey(key);
		MetricsProvider provider = getProvider(mk.getProvider());
		return provider.getValue(mk);
	}
622209
def metric_from_cell(cell):
    """"""
    cell = np.asarray(cell, dtype=float)
    return np.dot(cell, cell.T)
465647
def get_metric_time_series(self, mts_id, **kwargs):
        """"""
        return self._get_object_by_name(self._MTS_ENDPOINT_SUFFIX,
                                        mts_id,
                                        **kwargs)
798563
def metric(cls, name, count, elapsed):
        

        if name is None:
            warnings.warn("Ignoring unnamed metric", stacklevel=3)
            return

        with cls.lock:
            if not cls.instances:
                # first call
                shutil.rmtree(cls.outdir, ignore_errors=True)
                os.makedirs(cls.outdir)

                if cls.dump_atexit: atexit.register(cls.dump)

            try:
                self = cls.instances[name]
            except KeyError:
                self = cls.instances[name] = cls(name)

            self.writer.writerow((count, "%f"%elapsed))
5156
function(metric_type, metric) {
	var ary = metric.split('.');
	if (options.prefix) ary.shift();
	ary.unshift(metric_type);
	return ary.join('.')+'_'+options.rate;
}
470335
def _get_metric(self, metric, tablename, index_name=None):
        
        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
1088395
def get_current(self):
        """"""
        now = dt.now().timestamp()
        url = build_url(self.api_key, self.spot_id, self.fields,
                        self.unit, now, now)
        return get_msw(url)