(self, metric)
Process a metric and send it to RabbitMQ topic exchange
Process a metric and send it to RabbitMQ topic exchange
Process a metric and send it to RabbitMQ topic exchange
def process(self, metric):
        """
          Process a metric and send it to RabbitMQ topic exchange
        """
        # Send the data as ......
        if not pika:
            return

        routingKeyDic = {
            'metric': lambda: metric.path,
            'custom': lambda: self.custom_routing_key,

            # These option and the below are really not needed because
            #  with Rabbitmq you can use regular expressions to indicate
            #  what routing_keys to subscribe to. But I figure this is
            #  a good example of how to allow more routing keys

            '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:  # Rough connection re-try logic.
            self.log.info(
                "Failed publishing to rabbitMQ. Attempting reconnect")
            self._bind()
def process ( self , metric ) : # Send the data as ...... if not pika : return routingKeyDic = { 'metric' : lambda : metric . path , 'custom' : lambda : self . custom_routing_key , # These option and the below are really not needed because #  with Rabbitmq you can use regular expressions to indicate #  what routing_keys to subscribe to. But I figure this is #  a good example of how to allow more routing keys '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 : # Rough connection re-try logic. self . log . info ( "Failed publishing to rabbitMQ. Attempting reconnect" ) self . _bind ( )