def process(self, metric):
        """
        Process a metric by sending it to pub/sub
        :param metric: metric to process
        """
        if self.batch is None:
            self.metrics.append(self._convert_to_pubsub(metric))
            self._send()
        else:
            if self.batch == 'count':
                # batch up by number of msgs
                self.metrics.append(self._convert_to_pubsub(metric))
                if len(self.metrics) >= self.batch_size:
                    self._send()
            else:
                # batch up by size of msgs
                tmp_msg = self._convert_to_pubsub(metric)
                avg_size = \
                    len(json.dumps(self.metrics)) / (len(self.metrics) + 1)

                # TODO: see if there is a better way than json.dumps to get
                # byte size.
                next_bytecount = len(tmp_msg) + len(json.dumps(self.metrics))
                logging.debug("Next dataframe size: %s | Avg size: %s" %
                              (next_bytecount, avg_size))
                # add additional avg message size to cover msg envelope
                # overhead
                if next_bytecount >= \
                        ((self.batch_size - len(tmp_msg)) - avg_size):
                    self._send()

                self.metrics.append(tmp_msg)

        Process a metric by sending it to pub/sub
        :param metric: metric to process
        
src/diamond/handler/pubsub.py