Compare the available metrics for one MOR we have computed and intersect them
        with the set of metrics we want to report
169166
def _compute_needed_metrics(self, instance, available_metrics):
        
        i_key = self._instance_key(instance)
        if self.in_compatibility_mode(instance):
            if instance.get('all_metrics', False):
                return available_metrics

            wanted_metrics = []
            # Get only the basic metrics
            for counter_id in available_metrics:
                # No cache yet, skip it for now
                if not self.metadata_cache.contains(i_key, counter_id):
                    self.log.debug(
                        "No metadata found for counter {}, will not collect it".format(ensure_unicode(counter_id))
                    )
                    continue
                metadata = self.metadata_cache.get_metadata(i_key, counter_id)
                if metadata.get('name') in BASIC_METRICS:
                    wanted_metrics.append(vim.PerformanceManager.MetricId(counterId=counter_id, instance="*"))

            return wanted_metrics
        else:
            # The metadata cache contains only metrics of the desired level, so use it to filter the metrics to keep
            return [
                vim.PerformanceManager.MetricId(counterId=counter_id, instance="*")
                for counter_id in available_metrics
                if self.metadata_cache.contains(i_key, counter_id)
            ]
515951
def collect(self):
        
        logger.debug("Collecting metrics")

        for name, metricset in compat.iteritems(self._metricsets):
            data = metricset.collect()
            if data:
                self._queue_func(constants.METRICSET, data)
590131
private void getMetrics(
      MBeanServerConnection con,
      MetricFilter filter,
      List<Metric> metrics,
      ObjectName name)
      throws JMException, IOException {
    // Create tags from the object name
    TagList tags = createTagList(name);
    MBeanInfo info = con.getMBeanInfo(name);
    MBeanAttributeInfo[] attrInfos = info.getAttributes();

    // Restrict to attributes that match the filter
    List<String> matchingNames = new ArrayList<>();
    for (MBeanAttributeInfo attrInfo : attrInfos) {
      String attrName = attrInfo.getName();
      if (filter.matches(new MonitorConfig.Builder(attrName).withTags(tags).build())) {
        matchingNames.add(attrName);
      }
    }
    List<Attribute> attributeList = safelyLoadAttributes(con, name, matchingNames);

    for (Attribute attr : attributeList) {
      String attrName = attr.getName();
      Object obj = attr.getValue();
      if (obj instanceof TabularData) {
        ((TabularData) obj).values().stream()
            .filter(key -> key instanceof CompositeData)
            .forEach(key -> addTabularMetrics(filter, metrics, tags, attrName,
                (CompositeData) key));
      } else if (obj instanceof CompositeData) {
        addCompositeMetrics(filter, metrics, tags, attrName, (CompositeData) obj);
      } else {
        addMetric(metrics, attrName, tags, obj);
      }
    }
  }
1178709
def get_metrics(self):
        
        now = datetime.utcnow()
        metrics = set()
        for gauge in self.gauges.values():
            metrics.add(gauge.get_metric(now))
        return metrics
143686
def __get_metrics(self):
        
        esfilters_merge = None
        esfilters_abandon = None
        if self.esfilters:
            esfilters_merge = self.esfilters.copy()
            esfilters_abandon = self.esfilters.copy()

        merged = Merged(self.es_url, self.es_index,
                        start=self.start, end=self.end,
                        esfilters=esfilters_merge, interval=self.interval)

        abandoned = Abandoned(self.es_url, self.es_index,
                              start=self.start, end=self.end,
                              esfilters=esfilters_abandon, interval=self.interval)
        return (merged, abandoned)
151775
def _compare_mp_alias(br_i, br_j, analysis_set, analysis_set_subdir, unique_ajps, verbose):
    
    return br_i.compare(br_j, analysis_set, analysis_set_subdir, unique_ajps, verbose = verbose, compile_pdf = verbose)
698558
def check_metric(self, metric):
        """"""
        if metric not in self.VALID_METRICS:
            raise ValueError(
                f"`{self.__class__.__name__}` does not support the `{metric}` "
                f"metric. Please choose one of the supported metrics: "
                f"{', '.join(self.VALID_METRICS)}."
            )
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)
630436
def metrics(self):
        
        masterThrp, backupThrp = self.getThroughputs(self.instances.masterId)
        r = self.instance_throughput_ratio(self.instances.masterId)
        m = [
            ("{} Monitor metrics:".format(self), None),
            ("Delta", self.Delta),
            ("Lambda", self.Lambda),
            ("Omega", self.Omega),
            ("instances started", self.instances.started),
            ("ordered request counts",
             {i: r[0] for i, r in self.numOrderedRequests.items()}),
            ("ordered request durations",
             {i: r[1] for i, r in self.numOrderedRequests.items()}),
            ("master request latencies", self.masterReqLatencies),
            ("client avg request latencies", {i: self.getLatency(i)
                                              for i in self.instances.ids}),
            ("throughput", {i: self.getThroughput(i)
                            for i in self.instances.ids}),
            ("master throughput", masterThrp),
            ("total requests", self.totalRequests),
            ("avg backup throughput", backupThrp),
            ("master throughput ratio", r)]
        return m
147884
private void calculateAvailableMeasures() {

        boolean measureAvailable = true;

        measures = new ArrayList<HLAMeasure>();

        for (HLAMeasure currMeasure : HLAMeasure.values()) {

            measureAvailable = true;

            for (IProject currProject : getProjects()) {

                LOG.debug("Checking measure " + currMeasure.getSonarName() + " for project " + currProject);

                if (isNoMeasureAvailable(currMeasure, currProject)) {

                    measureAvailable = false;
                    break;
                }
            }

            if (measureAvailable)
                measures.add(currMeasure);
            else
                LOG.warn("Measure " + currMeasure.getSonarName() + " not available in all projects. Cannot calculate!");
        }

        LOG.debug(measures.size() + " measures are available in aggregated project " + getName());
    }
1230049
private List<Metric> mapping(List<Metric> metrics) {
        SystemAssert.requireArgument(metrics != null, "Cannot transform empty metric/metrics");
        if (metrics.isEmpty()) {
            return metrics;
        }

        List<Metric> newMetricsList = new ArrayList<Metric>();

        for (Metric metric : metrics) {
            Map<Long, Double> cleanDatapoints = cleanDPs(metric.getDatapoints());

            metric.setDatapoints(this.valueMapping.mapping(cleanDatapoints));
            newMetricsList.add(metric);
        }
        return newMetricsList;
    }
595743
def list_metrics(ctx):
    """"""
    config = ctx.obj["CONFIG"]

    if not exists(config):
        handle_no_cache(ctx)

    from wily.commands.list_metrics import list_metrics

    list_metrics()
1367355
def benchmark_multi(optimizer):
    """"""
    # Get our benchmark stats
    all_stats = benchmark.compare(optimizer, PROBLEMS, runs=100)
    return benchmark.aggregate(all_stats)
868182
def _get_current_dup_metrics(self, align_bam):
        
        metrics_file = "%s.dup_metrics" % os.path.splitext(align_bam)[0]
        if not file_exists(metrics_file):
            dups = 0
            with pysam.Samfile(align_bam, "rb") as bam_handle:
                for read in bam_handle:
                    if (read.is_paired and read.is_read1) or not read.is_paired:
                        if read.is_duplicate:
                            dups += 1
            with open(metrics_file, "w") as out_handle:
                out_handle.write("# custom bcbio-nextgen metrics\n")
                out_handle.write("READ_PAIR_DUPLICATES\t%s\n" % dups)
        return metrics_file
1090101
def assert_metric(self, name, value=None, tags=None, count=None, at_least=1, hostname=None, metric_type=None):
        
        self._asserted.add(name)
        tags = normalize_tags(tags, sort=True)

        candidates = []
        for metric in self.metrics(name):
            if value is not None and not self.is_aggregate(metric.type) and value != metric.value:
                continue

            if tags and tags != sorted(metric.tags):
                continue

            if hostname and hostname != metric.hostname:
                continue

            if metric_type is not None and metric_type != metric.type:
                continue

            candidates.append(metric)

        if value is not None and candidates and all(self.is_aggregate(m.type) for m in candidates):
            got = sum(m.value for m in candidates)
            msg = "Expected count value for '{}': {}, got {}".format(name, value, got)
            assert value == got, msg

        if count is not None:
            msg = "Needed exactly {} candidates for '{}', got {}".format(count, name, len(candidates))
            assert len(candidates) == count, msg
        else:
            msg = "Needed at least {} candidates for '{}', got {}".format(at_least, name, len(candidates))
            assert len(candidates) >= at_least, msg
1140275
def metrics(self):
        
        from vel.metrics.loss_metric import Loss
        from vel.metrics.accuracy import Accuracy
        return [Loss(), Accuracy()]
110652
def for(metric_operation, metric_name = nil)
      list = if metric_name
               all.find { |manifest| manifest.metric_operation == metric_operation.to_s && manifest.metric_name == metric_name.to_s }
             else
               all.find_all { |manifest| manifest.metric_operation == metric_operation.to_s }
             end
      list
    end