<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def send(self, data, sample_rate=1):
 """ Squirt the metrics over UDP """


        if self.prefix:
            data = dict((".".join((self.prefix, stat)), value) for stat, value in data.items())

        if sample_rate < 1:
            if random.random() > sample_rate:
                return
            sampled_data = dict((stat, "%s|@%s" % (value, sample_rate))
                                for stat, value in data.items())
        else:
            sampled_data = data

        try:
            [self.udp_sock.sendto(bytes(bytearray("%s:%s" % (stat, value),
                                                  "utf-8")), self.addr)
             for stat, value in sampled_data.items()]
        except:
            self.log.exception("unexpected error")