<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parse_metric(metric, metric_mapping=METRIC_TREE):
 """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_names = []
    tag_values = []
    tag_builder = []
    unknown_tags = []
    num_tags = 0
    minimum_tag_length = 0

    for metric_part in metric.split('.'):
        if metric_part in metric_mapping and num_tags >= minimum_tag_length:
            # Rebuild any built up tags whenever we encounter a known metric part.
            if tag_builder:
                for tags in metric_mapping['|_tags_|']:
                    if num_tags >= len(tags):
                        break

                constructed_tags = construct_tags(tag_builder, len(tags))

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

                num_tags = 0

            metric_parts.append(metric_part)
            metric_mapping = metric_mapping[metric_part]
            minimum_tag_length = len(metric_mapping['|_tags_|'][-1])
        else:
            tag_builder.append(metric_part)
            num_tags += 1

    metric = '.'.join(metric_parts)
    if metric not in METRICS:
        raise UnknownMetric

    # Rebuild any trailing tags
    if tag_builder:
        for tags in metric_mapping['|_tags_|']:
            if num_tags >= len(tags):
                break

        constructed_tags = construct_tags(tag_builder, len(tags))

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

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

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

    return METRIC_PREFIX + metric, tags, METRICS[metric]['method']