(metric, retry=False, metric_mapping=METRIC_TREE, disable_legacy_cluster_tag=False)
return METRIC_PREFIX + parsed_metric, tags, METRICS[parsed_metric]['method']
Takes a metric formatted by Envoy and splits it into a unique
    metric name. Returns the unique metric name, a list of tags, and
    the name of the submission method.

    Example:
        'listener.0.0.0.0_80.downstream_cx_total' ->
        ('listener.downstream_cx_total', ['address:0.0.0.0_80'], 'count')
Takes a metric formatted by Envoy and splits it into a unique
    metric name. Returns the unique metric name, a list of tags, and
    the name of the submission method.
Takes a metric formatted by Envoy and splits it into a unique metric name . Returns the unique metric name a list of tags and the name of the submission method .
def parse_metric(metric, retry=False, metric_mapping=METRIC_TREE, disable_legacy_cluster_tag=False):
    # type: (str, Dict[str, Any]) -> Tuple[str, List[str], str]
    """Takes a metric formatted by Envoy and splits it into a unique
    metric name. Returns the unique metric name, a list of tags, and
    the name of the submission method.

    Example:
        'listener.0.0.0.0_80.downstream_cx_total' ->
        ('listener.downstream_cx_total', ['address:0.0.0.0_80'], 'count')
    """
    metric_parts, tag_value_builder, tag_names, tag_values, unknown_tags, tags_to_build, last_mapping = _parse_metric(
        metric, metric_mapping
    )
    parsed_metric = '.'.join(metric_parts)
    if parsed_metric not in METRICS:
        if retry:
            skip_parts = []
            # Retry parsing for metrics by skipping the last matched metric part
            while len(metric_parts) > 1:
                skip_part = metric_parts.pop()
                if skip_part in skip_parts:
                    raise UnknownMetric
                else:
                    skip_parts.append(skip_part)
                (
                    metric_parts,
                    tag_value_builder,
                    tag_names,
                    tag_values,
                    unknown_tags,
                    tags_to_build,
                    last_mapping,
                ) = _parse_metric(metric, metric_mapping, skip_part)
                parsed_metric = '.'.join(metric_parts)
                if parsed_metric in METRICS:
                    break
            else:
                raise UnknownMetric
        else:
            raise UnknownMetric
    # Rebuild any trailing tags
    if tag_value_builder:
        tags = next(
            (mapped_tags for mapped_tags in last_mapping['|_tags_|'] if tags_to_build >= len(mapped_tags)), tuple()
        )
        constructed_tag_values = construct_tag_values(tag_value_builder, len(tags))

        if tags:
            tag_names.extend(tags)
            tag_values.extend(constructed_tag_values)
        else:
            unknown_tags.extend(constructed_tag_values)

    if unknown_tags:
        raise UnknownTags('{}'.format('|||'.join(unknown_tags)))

    if not disable_legacy_cluster_tag:
        for name, legacy_name in [('envoy_cluster', 'cluster_name'), ('virtual_envoy_cluster', 'virtual_cluster_name')]:
            try:
                pos = tag_names.index(name)
                tag_names.append(legacy_name)
                tag_values.append(tag_values[pos])
            except ValueError:
                pass

    tags = ['{}:{}'.format(tag_name, tag_value) for tag_name, tag_value in zip(tag_names, tag_values)]

    return METRIC_PREFIX + parsed_metric, tags, METRICS[parsed_metric]['method']
def parse_metric ( metric , retry = False , metric_mapping = METRIC_TREE , disable_legacy_cluster_tag = False ) : # type: (str, Dict[str, Any]) -> Tuple[str, List[str], str] metric_parts , tag_value_builder , tag_names , tag_values , unknown_tags , tags_to_build , last_mapping = _parse_metric ( metric , metric_mapping ) parsed_metric = '.' . join ( metric_parts ) if parsed_metric not in METRICS : if retry : skip_parts = [ ] # Retry parsing for metrics by skipping the last matched metric part while len ( metric_parts ) > 1 : skip_part = metric_parts . pop ( ) if skip_part in skip_parts : raise UnknownMetric else : skip_parts . append ( skip_part ) ( metric_parts , tag_value_builder , tag_names , tag_values , unknown_tags , tags_to_build , last_mapping , ) = _parse_metric ( metric , metric_mapping , skip_part ) parsed_metric = '.' . join ( metric_parts ) if parsed_metric in METRICS : break else : raise UnknownMetric else : raise UnknownMetric # Rebuild any trailing tags if tag_value_builder : tags = next ( ( mapped_tags for mapped_tags in last_mapping [ '|_tags_|' ] if tags_to_build >= len ( mapped_tags ) ) , tuple ( ) ) constructed_tag_values = construct_tag_values ( tag_value_builder , len ( tags ) ) if tags : tag_names . extend ( tags ) tag_values . extend ( constructed_tag_values ) else : unknown_tags . extend ( constructed_tag_values ) if unknown_tags : raise UnknownTags ( '{}' . format ( '|||' . join ( unknown_tags ) ) ) if not disable_legacy_cluster_tag : for name , legacy_name in [ ( 'envoy_cluster' , 'cluster_name' ) , ( 'virtual_envoy_cluster' , 'virtual_cluster_name' ) ] : try : pos = tag_names . index ( name ) tag_names . append ( legacy_name ) tag_values . append ( tag_values [ pos ] ) except ValueError : pass tags = [ '{}:{}' . format ( tag_name , tag_value ) for tag_name , tag_value in zip ( tag_names , tag_values ) ] return METRIC_PREFIX + parsed_metric , tags , METRICS [ parsed_metric ] [ 'method' ]