Resource limits by consumer type.

def kube_limitrange(self, metric, scraper_config):
        """ Resource limits by consumer type. """
        # type's cardinality's low: https://github.com/kubernetes/kubernetes/blob/v1.6.1/pkg/api/v1/types.go#L3872-L3879
        # idem for resource: https://github.com/kubernetes/kubernetes/blob/v1.6.1/pkg/api/v1/types.go#L3342-L3352
        # idem for constraint: https://github.com/kubernetes/kubernetes/blob/v1.6.1/pkg/api/v1/types.go#L3882-L3901
        metric_base_name = scraper_config['namespace'] + '.limitrange.{}.{}'
        constraints = {
            'min': 'min',
            'max': 'max',
            'default': 'default',
            'defaultRequest': 'default_request',
            'maxLimitRequestRatio': 'max_limit_request_ratio',
        }

        if metric.type in METRIC_TYPES:
            for sample in metric.samples:
                constraint = sample[self.SAMPLE_LABELS].get("constraint")
                if constraint in constraints:
                    constraint = constraints[constraint]
                else:
                    self.error("Constraint %s unsupported for metric %s" % (constraint, metric.name))
                    continue
                resource = sample[self.SAMPLE_LABELS].get("resource")
                tags = [
                    self._label_to_tag("namespace", sample[self.SAMPLE_LABELS], scraper_config),
                    self._label_to_tag("limitrange", sample[self.SAMPLE_LABELS], scraper_config),
                    self._label_to_tag("type", sample[self.SAMPLE_LABELS], scraper_config, tag_name="consumer_type"),
                ] + scraper_config['custom_tags']
                self.gauge(metric_base_name.format(resource, constraint), sample[self.SAMPLE_VALUE], tags)
        else:
            self.log.error("Metric type %s unsupported for metric %s" % (metric.type, metric.name))