Gets/Sets the metrics stats.

@param  array $metrics The metrics data to set if defined.
@return array          The metrics data.
979158
public function data($metrics = [])
    {
        if (func_num_args() === 0) {
            return $this->_metrics;
        }

        $this->_metrics = $metrics + $this->_metrics;

        if ($this->_metrics['lloc']) {
            $this->_metrics['percent'] = ($this->_metrics['cloc'] * 100) / $this->_metrics['lloc'];
        } else {
            $this->_metrics['percent'] = 100;
        }
    }
977370
async def get_metrics(self, *tags):
        
        log.debug("Retrieving metrics for %s",
                  ', '.join(tags) if tags else "all units")

        metrics_facade = client.MetricsDebugFacade.from_connection(
            self.connection())

        entities = [client.Entity(tag) for tag in tags]
        metrics_result = await metrics_facade.GetMetrics(entities)

        metrics = collections.defaultdict(list)

        for entity_metrics in metrics_result.results:
            error = entity_metrics.error
            if error:
                if "is not a valid tag" in error:
                    raise ValueError(error.message)
                else:
                    raise Exception(error.message)

            for metric in entity_metrics.metrics:
                metrics[metric.unit].append(vars(metric))

        return metrics
213785
public function showMetrics()
    {
        $metrics = Metric::orderBy('order')->orderBy('id')->get();

        return View::make('dashboard.metrics.index')
            ->withPageTitle(trans('dashboard.metrics.metrics').' - '.trans('dashboard.dashboard'))
            ->withMetrics($metrics);
    }
826098
def _get_metrics_record(xapi, rectype, record):
    '''
    
    '''
    metrics_id = record['metrics']
    return getattr(xapi, '{0}_metrics'.format(rectype)).get_record(metrics_id)
807981
public function getCampaignSeries()
    {
        $locationFacts = $this->getLocationFacts();
        $seriesData = [];
        $metricIds = [];

        foreach ($locationFacts as $locationFact) {
            $factsData = $this->getFacts($locationFact->getLocation());
            $seriesData[] = [
                'location' => $locationFact->getLocation(),
                'dimensions' => $factsData,
            ];

            $usedMetricIds = array_keys($factsData);
            foreach ($usedMetricIds as $metricId) {
                if (in_array($metricId, $metricIds)) {
                    continue;
                }
                $metricIds[] = $metricId;
            }
        }

        return [
            'data' => $seriesData,
            'metricNames' => $this->getMetricNamesById($metricIds),
        ];
    }
674563
public function getMetric($name) {
        if (isset($this->metrics[$name])) {
            return $this->metrics[$name];
        }

        throw new MetricNotFoundException("Metric $name not found");
    }
1297617
public function getPointsSinceMinutes(Metric $metric, $minutes)
    {
        $queryType = $this->getQueryType($metric);

        $points = DB::select("SELECT DATE_FORMAT({$this->getMetricPointsTable()}.`created_at`, '%Y-%m-%d %H:%i') AS `key`, {$queryType} ".
            "FROM {$this->getMetricsTable()} INNER JOIN {$this->getMetricPointsTable()} ON {$this->getMetricsTable()}.id = {$this->getMetricPointsTable()}.metric_id ".
            "WHERE {$this->getMetricsTable()}.id = :metricId ".
            "AND {$this->getMetricPointsTable()}.`created_at` >= DATE_SUB(NOW(), INTERVAL :minutes MINUTE) ".
            "AND {$this->getMetricPointsTable()}.`created_at` <= NOW() ".
            "GROUP BY HOUR({$this->getMetricPointsTable()}.`created_at`), MINUTE({$this->getMetricPointsTable()}.`created_at`) ORDER BY {$this->getMetricPointsTable()}.`created_at`", [
            'metricId' => $metric->id,
            'minutes'  => $minutes,
        ]);

        return $this->mapResults($metric, $points);
    }
934525
public function statistics(array $statistics) {
		if ($this->_isCli) {
			return $this->_none('Not allowed in cli');
		}
		if (!$this->settings['chartEnabled']) {
			return $this->_none('Please install <b>imsamurai/cakephp-google-chart</b> plugin to view graph');
		}
		if (empty($statistics)) {
			return $this->_none();
		}
		
		$this->GoogleChart->load();

		$chartData = $this->GoogleChart->dataFromArray(array(
			'memory' => array_map('floatval', Hash::extract($statistics, '{n}.memory')),
			'cpu' => array_map('floatval', Hash::extract($statistics, '{n}.cpu')),
			'date' => array_map('strtotime', Hash::extract($statistics, '{n}.created')),
			'statistics' => $statistics
				), array(
			'date' => array(
				'v' => 'date.{n}',
				'f' => 'statistics.{n}.created'
			),
			'memory' => 'memory.{n}',
			'cpu' => 'cpu.{n}',
			'{"role": "annotation"}' => 'statistics.{n}.status',
				)
		);

		return $this->GoogleChart->draw('LineChart', $chartData, array(
			'height' => 300,
			'width' => 800,
			'pointSize' => 5,
			'vAxis' => array(
				'title' => 'Percentage'
			),
			'hAxis' => array(
				'title' => 'Time'
			),
			'chartArea' => array(
				'left' => 50,
				'top' => 10,
				'height' => 230,
				'width' => 650,
			)
				)
		);
	}
318074
def __get_metrics(self):
        
        esfilters_closed = None
        esfilters_opened = None
        if self.esfilters:
            esfilters_closed = self.esfilters.copy()
            esfilters_opened = self.esfilters.copy()

        closed = self.closed_class(self.es_url, self.es_index,
                                   start=self.start, end=self.end,
                                   esfilters=esfilters_closed, interval=self.interval)
        opened = self.opened_class(self.es_url, self.es_index,
                                   start=self.start, end=self.end,
                                   esfilters=esfilters_opened, interval=self.interval)
        return (closed, opened)
1173036
public function getMetrics()
    {
        if ($this->metrics === null) {
            $this->metrics = new Metrics($this->coverage);
        }

        return $this->metrics;
    }
1290088
public function getPointsSinceDay(Metric $metric, $day)
    {
        $queryType = $this->getQueryType($metric);
        $points = DB::select("SELECT DATE_FORMAT({$this->getMetricPointsTable()}.`created_at`, '%Y-%m-%d') AS `key`, {$queryType} ".
            "FROM {$this->getMetricsTable()} INNER JOIN {$this->getMetricPointsTable()} ON {$this->getMetricsTable()}.id = {$this->getMetricPointsTable()}.metric_id ".
            "WHERE {$this->getMetricsTable()}.id = :metricId ".
            "AND {$this->getMetricPointsTable()}.`created_at` >= DATE_SUB(NOW(), INTERVAL :day DAY) ".
            "AND {$this->getMetricPointsTable()}.`created_at` <= NOW() ".
            "GROUP BY DATE({$this->getMetricPointsTable()}.`created_at`) ORDER BY {$this->getMetricPointsTable()}.`created_at`", [
            'metricId' => $metric->id,
            'day'      => $day,
        ]);

        return $this->mapResults($metric, $points);
    }
568359
protected static function _exportMetrics($xmlDocument, $metrics)
    {
        $data = $metrics->data();
        $xmlMetrics = $xmlDocument->createElement('metrics');
        $xmlMetrics->setAttribute('loc', $data['loc']);
        $xmlMetrics->setAttribute('ncloc', $data['nlloc']);
        $xmlMetrics->setAttribute('statements', $data['lloc']);
        $xmlMetrics->setAttribute('coveredstatements', $data['cloc']);
        return $xmlMetrics;
    }
883020
public function end($metric, array $tags = array())
    {
        try {
            if (!isset($this->timers[$metric])) {
                throw new \RuntimeException("Timer for metric $metric was not started");
            }

            if (!empty($tags)) {
                $this->timers[$metric]->setTags(array_merge($this->timers[$metric]->getTags(), $tags));
            }

            $this->sendMetric($this->timers[$metric]->end());
            unset ($this->timers[$metric]);

        } catch (\Exception $exception) {
            $this->logException($exception);
        }

        return $this;
    }
1286558
private function getData(AbstractMetric $metric)
    {
        return array(
            'type'        => $metric->getType(),
            'name'        => $metric->getName(),
            'value'       => $metric->getValue(),
            'sample_rate' => $metric->getSampleRate()
        );
    }
49644
protected function _renderCoverage($metrics)
    {
        $stats = $metrics->data();
        foreach ($stats['files'] as $file) {
            $this->write("File: {$file}" . "\n\n");

            $lines = file($file);

            $coverage = $this->_collector->export($file);

            if (isset($stats['line'])) {
                $start = $stats['line']['start'];
                $stop = $stats['line']['stop'];
            } else {
                $start = 0;
                $stop = count($lines) - 1;
            }

            for ($i = $start; $i <= $stop; $i++) {
                $value = isset($coverage[$i]) ? $coverage[$i] : null;
                $line = str_pad($i + 1, 6, ' ', STR_PAD_LEFT);
                $line .= ':' . str_pad($value, 6, ' ');
                $line .= $lines[$i];
                if ($value) {
                    $this->write($line, 'n;green');
                } elseif ($value === 0) {
                    $this->write($line, 'n;red');
                } else {
                    $this->write($line);
                }
            }
            $this->write("\n\n");
        }
    }
792090
public function applyMetrics($qb, &$metrics, $associationMappings, $classMetadata, $joins)
    {
        foreach ($metrics as $metricItemKey => $metricItem) {
            $metric = $metricItem['field'];
            $metric_name = str_replace('.', '___', $metric) . '___' . $metricItem['aggregation'];
            $metrics[$metricItemKey]['code_name'] = $metric_name;

            if (false !== mb_strpos($metric, '.')) {
                $metric_parts = explode('.', $metric);
                $metrics[$metricItemKey]['label_name'] = $this->camelCaseToUnderscore($metric_parts[0]);

                /** @var array $associationMapping */
                $associationMapping = $associationMappings[$metric_parts[0]];

                $associationTargetClass = $classMetadata->getAssociationTargetClass($metric_parts[0]);

                $on = '';

                /** @var array $sourceToTargetKeyColumns */
                $sourceToTargetKeyColumns = $associationMapping['sourceToTargetKeyColumns'];

                foreach ($sourceToTargetKeyColumns as $source => $target) {
                    $on = 'entity.' . $source . ' = ' . $metric_parts[0] . '_join';
                }

                if (!\in_array($associationTargetClass, $joins)) {
                    $joins[] = $associationTargetClass;
                    $qb->leftJoin($associationTargetClass, $metric_parts[0] . '_join', 'WITH', $on);
                }

                $qb->addSelect($metricItem['aggregation'] . '(' . $metric . ') as ' . $metric_name);
            } else {
                $metrics[$metricItemKey]['label_name'] = $this->camelCaseToUnderscore($metric);

                $qb->addSelect($metricItem['aggregation'] . '(' . 'entity.' . $metric . ') as ' . $metric_name);
            }
        }

        return $qb;
    }
1299803
def get_metrics(tag):
    
    if tag is None:
        return metrics.metrics_by_name_list(metrics.metrics())
    else:
        return metrics.metrics_by_tag(tag)