(self, instance, mors)
Process a batch of items popped from the objects queue by querying the available
        metrics for these MORs and then putting them in the Mor cache
Process a batch of items popped from the objects queue by querying the available
        metrics for these MORs and then putting them in the Mor cache
Process a batch of items popped from the objects queue by querying the available metrics for these MORs and then putting them in the Mor cache
def _process_mor_objects_queue_async(self, instance, mors):
        """
        Process a batch of items popped from the objects queue by querying the available
        metrics for these MORs and then putting them in the Mor cache
        """
        t = time.time()
        i_key = self._instance_key(instance)
        server_instance = self._get_server_instance(instance)
        perfManager = server_instance.content.perfManager

        # For non realtime metrics, we need to specifically ask which counters are available for which entity,
        # so we call perfManager.QueryAvailablePerfMetric for each cluster, datacenter, datastore
        # This should be okay since the number of such entities shouldn't be excessively large
        for mor in mors:
            mor_name = str(mor['mor'])
            available_metrics = {m.counterId for m in perfManager.QueryAvailablePerfMetric(entity=mor["mor"])}
            try:
                self.mor_cache.set_metrics(i_key, mor_name, self._compute_needed_metrics(instance, available_metrics))
            except MorNotFoundError:
                self.log.error("Object '%s' is missing from the cache, skipping. ", ensure_unicode(mor_name))
                continue

        # TEST-INSTRUMENTATION
        custom_tags = instance.get('tags', []) + ['instance:{}'.format(i_key)]
        self.histogram('datadog.agent.vsphere.morlist_process_atomic.time', time.time() - t, tags=custom_tags)
def _process_mor_objects_queue_async ( self , instance , mors ) : t = time . time ( ) i_key = self . _instance_key ( instance ) server_instance = self . _get_server_instance ( instance ) perfManager = server_instance . content . perfManager # For non realtime metrics, we need to specifically ask which counters are available for which entity, # so we call perfManager.QueryAvailablePerfMetric for each cluster, datacenter, datastore # This should be okay since the number of such entities shouldn't be excessively large for mor in mors : mor_name = str ( mor [ 'mor' ] ) available_metrics = { m . counterId for m in perfManager . QueryAvailablePerfMetric ( entity = mor [ "mor" ] ) } try : self . mor_cache . set_metrics ( i_key , mor_name , self . _compute_needed_metrics ( instance , available_metrics ) ) except MorNotFoundError : self . log . error ( "Object '%s' is missing from the cache, skipping. " , ensure_unicode ( mor_name ) ) continue # TEST-INSTRUMENTATION custom_tags = instance . get ( 'tags' , [ ] ) + [ 'instance:{}' . format ( i_key ) ] self . histogram ( 'datadog.agent.vsphere.morlist_process_atomic.time' , time . time ( ) - t , tags = custom_tags )