def _convert_to_pubsub(self, metric):
        """
        Convert a metric to a dictionary representing a Pub/Sub event.
        Each metric should be loaded into a separate data slot
        """
        # Using separate "host" field, so remove from the path.
        # This was taken from the Riemann Handler.
        path = '%s.%s.%s' % (
            metric.getPathPrefix(),
            metric.getCollectorPath(),
            metric.getMetricPath()
        )

        payload = {
            'host': metric.host,
            'service': path,
            'time': metric.timestamp,
            'metric': float(metric.value),
            'ttl': metric.ttl,
            'tags': self.tags,
            }
        data = base64.b64encode(json.dumps(payload))

        return {'data': data}

        Convert a metric to a dictionary representing a Pub/Sub event.
        Each metric should be loaded into a separate data slot
        
src/diamond/handler/pubsub.py