def METHOD_NAME(self, data, addr):
    LOG.debug("Received data `%r' from %s", data, addr)
    try:
        messages = [m for m in data.decode().split("\n") if m]
    except Exception as e:
        LOG.error("Unable to decode datagram: %s", e)
        return
    for message in messages:
        metric = message.split("|")
        if len(metric) == 2:
            metric_name, metric_type = metric
            sampling = None
        elif len(metric) == 3:
            metric_name, metric_type, sampling = metric
        else:
            LOG.error("Invalid number of | in `%s'", message)
            continue
        sampling = float(sampling[1:]) if sampling is not None else None
        metric_name, metric_str_val = metric_name.split(':')
        # NOTE(jd): We do not support +/- gauge, and we delete gauge on
        # each flush.
        value = float(metric_str_val)
        try:
            self.stats.treat_metric(metric_name, metric_type,
                                    value, sampling)
        except Exception as e:
            LOG.error("Unable to treat metric %s: %s", message, str(e))