

def parse_metric_packet(self, packet):
    '\n        Schema of a dogstatsd packet:\n        <name>:<value>|<metric_type>|@<sample_rate>|#<tag1_name>:<tag1_value>,<tag2_name>:<tag2_value>:<value>|<metric_type>...\n        '
    parsed_packets = []
    name_and_metadata = packet.split(':', 1)
    if (len(name_and_metadata) != 2):
        raise Exception(('Unparseable metric packet: %s' % packet))
    name = name_and_metadata[0]
    broken_split = name_and_metadata[1].split(':')
    data = []
    partial_datum = None
    for token in broken_split:
        if (partial_datum is None):
            partial_datum = token
        elif ('|' not in token):
            partial_datum += (':' + token)
        else:
            data.append(partial_datum)
            partial_datum = token
    data.append(partial_datum)
    for datum in data:
        value_and_metadata = datum.split('|')
        if (len(value_and_metadata) < 2):
            raise Exception(('Unparseable metric packet: %s' % packet))
        raw_value = value_and_metadata[0]
        metric_type = value_and_metadata[1]
        if (metric_type in self.ALLOW_STRINGS):
            value = raw_value
        else:
            try:
                value = int(raw_value)
            except ValueError:
                try:
                    value = float(raw_value)
                except ValueError:
                    raise Exception(('Metric value must be a number: %s, %s' % (name, raw_value)))
        sample_rate = 1
        tags = None
        for m in value_and_metadata[2:]:
            if (m[0] == '@'):
                sample_rate = float(m[1:])
                assert (0 <= sample_rate <= 1)
            elif (m[0] == '#'):
                tags = tuple(sorted(m[1:].split(',')))
        parsed_packets.append((name, value, metric_type, tags, sample_rate))
    return tags

dataset/ETHPy150Open serverdensity/sd-agent/aggregator.py Aggregator.parse_metric_packet/VarMisuse@373/599 `parsed_packets`->`tags`