

def process(self, metric):
    '\n          Process a metric and send it to RabbitMQ topic exchange\n        '
    if (not pika):
        return
    routingKeyDic = {
        'metric': (lambda : metric.path),
        'custom': (lambda : self.custom_routing_key),
        'host': (lambda : metric.host),
        'metric.path': metric.getMetricPath,
        'path.prefix': metric.getPathPrefix,
        'collector.path': metric.getCollectorPath,
    }
    try:
        self.channel.basic_publish(exchange=self.topic_exchange, routing_key=routingKeyDic[self.routing_key](), body=('%s' % metric))
    except Exception:
        self.log.info('Failed publishing to rabbitMQ. Attempting reconnect')
        self._bind()

dataset/ETHPy150Open BrightcoveOS/Diamond/src/diamond/handler/rabbitmq_topic.py rmqHandler.process/original