Return the Metrics on this shelf in the order in which
        they were used.
423434
def filter_ids(self):
        
        return self._sorted_ingredients([
            d.id for d in self.values() if isinstance(d, Filter)
        ])
858691
def measures(self):
        """"""
        from ambry.valuetype.core import ROLE

        return [c for c in self.columns if c.role == ROLE.MEASURE]
795642
def sort_entries(self):
        """"""
        return sorted(self.data, key=self.sort_func, reverse=self.get_reverse())
88495
def get_ordering(self):
        
        #noinspection PyUnresolvedReferences
        ordering = self.request.GET.get('ordering', None)

        if ordering not in ['title', '-created_at']:
            ordering = '-created_at'

        return ordering
472231
def collect(self):
        """"""
        def traverse(d, metric_name=''):
            """
            Traverse the given nested dict using depth-first search.

            If a value is reached it will be published with a metric name
            consisting of the hierarchically concatenated keys
            of its branch.
            """
            for key, value in d.iteritems():
                if isinstance(value, dict):
                    if metric_name == '':
                        metric_name_next = key
                    else:
                        metric_name_next = metric_name + '.' + key
                    traverse(value, metric_name_next)
                else:
                    metric_name_finished = metric_name + '.' + key
                    self.publish_gauge(
                        name=metric_name_finished,
                        value=value,
                        precision=1
                    )

        md_state = self._parse_mdstat()

        traverse(md_state, '')
1084604
def metrics(self):
        
        return dict(
            (name, getattr(Metrics, config['type']))
            for name, config in six.iteritems(self._metrics)
        )
731646
def collect_metrics(self):
        
        try:
            g = None
            u = resource.getrusage(resource.RUSAGE_SELF)
            if gc_.isenabled():
                c = list(gc_.get_count())
                th = list(gc_.get_threshold())
                g = GC(collect0=c[0] if not self.last_collect else c[0] - self.last_collect[0],
                       collect1=c[1] if not self.last_collect else c[
                           1] - self.last_collect[1],
                       collect2=c[2] if not self.last_collect else c[
                           2] - self.last_collect[2],
                       threshold0=th[0],
                       threshold1=th[1],
                       threshold2=th[2])

            thr = threading.enumerate()
            daemon_threads = [tr.daemon is True for tr in thr].count(True)
            alive_threads = [tr.daemon is False for tr in thr].count(True)
            dummy_threads = [type(tr) is threading._DummyThread for tr in thr].count(True)

            m = Metrics(ru_utime=u[0] if not self.last_usage else u[0] - self.last_usage[0],
                        ru_stime=u[1] if not self.last_usage else u[1] - self.last_usage[1],
                        ru_maxrss=u[2],
                        ru_ixrss=u[3],
                        ru_idrss=u[4],
                        ru_isrss=u[5],
                        ru_minflt=u[6] if not self.last_usage else u[6] - self.last_usage[6],
                        ru_majflt=u[7] if not self.last_usage else u[7] - self.last_usage[7],
                        ru_nswap=u[8] if not self.last_usage else u[8] - self.last_usage[8],
                        ru_inblock=u[9] if not self.last_usage else u[9] - self.last_usage[9],
                        ru_oublock=u[10] if not self.last_usage else u[10] - self.last_usage[10],
                        ru_msgsnd=u[11] if not self.last_usage else u[11] - self.last_usage[11],
                        ru_msgrcv=u[12] if not self.last_usage else u[12] - self.last_usage[12],
                        ru_nsignals=u[13] if not self.last_usage else u[13] - self.last_usage[13],
                        ru_nvcs=u[14] if not self.last_usage else u[14] - self.last_usage[14],
                        ru_nivcsw=u[15] if not self.last_usage else u[15] - self.last_usage[15],
                        alive_threads=alive_threads,
                        dummy_threads=dummy_threads,
                        daemon_threads=daemon_threads,
                        gc=g)

            self.last_usage = u
            if gc_.isenabled():
                self.last_collect = c

            return m
        except:
            logger.debug("collect_metrics", exc_info=True)
388007
def get_context_data(self, **kwargs):
        """"""
        data = super(MetricsListView, self).get_context_data(**kwargs)

        # Metrics organized by category, like so:
        # { <category_name>: [ <slug1>, <slug2>, ... ]}
        data.update({'metrics': get_r().metric_slugs_by_category()})
        return data
540856
def list_metrics(self, entity, check, limit=None, marker=None,
            return_next=False):
        
        return entity.list_metrics(check, limit=limit, marker=marker,
                return_next=return_next)
6521
def get_metric(self, slug):
        
        results = OrderedDict()
        granularities = self._granularities()
        keys = self._build_keys(slug)
        for granularity, key in zip(granularities, keys):
            results[granularity] = self.r.get(key)
        return results
695380
def metric(slug, num=1, category=None, expire=None, date=None):
    """"""
    get_r().metric(slug, num=num, category=category, expire=expire, date=date)
411232
def _get_metrics_to_collect(self, instance_key, additional_metrics):
        
        if instance_key not in self.metrics_to_collect_by_instance:
            self.metrics_to_collect_by_instance[instance_key] = self._build_metric_list_to_collect(additional_metrics)
        return self.metrics_to_collect_by_instance[instance_key]
528062
def ordered_dirs(self):
        
        return [item[0] for item in sorted(
            self.byte_contents.items(), key=lambda entry: entry[1].st_ino)]
596375
def list_metrics(self, limit=None, marker=None, return_next=False):
        
        return self._metrics_manager.list(limit=limit, marker=marker,
                return_next=return_next)
986169
def _sort(self):
        
        self.versions = OrderedDict(sorted(self.versions.items(), key=lambda v: v[0]))
1261359
def ranks(self) -> List[str]:
        """"""
        return list(OrderedDict.fromkeys((m.rank for m in self.members)))
2427
def list():
    ''''''
    for cls, metrics in metric_catalog.items():
        echo(white(cls.__name__))

        for metric in metrics.keys():
            echo('> {0}'.format(metric))