

def _report(self, metric, metric_type, value, tags, sample_rate):
    "\n        Create a metric packet and send it.\n\n        More information about the packets' format: http://docs.datadoghq.com/guides/dogstatsd/\n        "
    if (value is None):
        return
    if ((sample_rate != 1) and (random() > sample_rate)):
        return
    payload = []
    if self.constant_tags:
        if tags:
            tags = (tags + self.constant_tags)
        else:
            tags = self.constant_tags
    if self.namespace:
        payload.extend([self.namespace, '.'])
    payload.extend([metric, ':', value, '|', metric_type])
    if (sample_rate != 1):
        payload.extend(['|@', sample_rate])
    if tags:
        payload.extend(['|#', ','.join(tags)])
    encoded = ''.join(imap(str, payload))
    self._send(encoded)

dataset/ETHPy150Open DataDog/datadogpy/datadog/dogstatsd/base.py DogStatsd._report/original