(self, infrastructure_data)
return mor_tags
Fetch the all tags, build tags for each monitored resources and store all of that into the tags_cache.
Fetch the all tags, build tags for each monitored resources and store all of that into the tags_cache.
Fetch the all tags build tags for each monitored resources and store all of that into the tags_cache .
def collect_tags(self, infrastructure_data):
        # type: (InfrastructureData) -> ResourceTags
        """
        Fetch the all tags, build tags for each monitored resources and store all of that into the tags_cache.
        """
        if not self.api_rest:
            return {}

        # In order to be more efficient in tag collection, the infrastructure data is filtered as much as possible.
        # All filters are applied except the ones based on tags of course.
        resource_filters_without_tags = [f for f in self._config.resource_filters if not isinstance(f, TagFilter)]
        filtered_infra_data = {
            mor: props
            for mor, props in iteritems(infrastructure_data)
            if isinstance(mor, tuple(self._config.collected_resource_types))
            and is_resource_collected_by_filters(mor, infrastructure_data, resource_filters_without_tags)
        }

        t0 = Timer()
        mors_list = list(filtered_infra_data.keys())
        try:
            mor_tags = self.api_rest.get_resource_tags_for_mors(mors_list)
        except Exception as e:
            self.log.error("Failed to collect tags: %s", e)
            return {}

        self.gauge(
            'datadog.vsphere.query_tags.time',
            t0.total(),
            tags=self._config.base_tags,
            raw=True,
            hostname=self._hostname,
        )

        return mor_tags
def collect_tags ( self , infrastructure_data ) : # type: (InfrastructureData) -> ResourceTags if not self . api_rest : return { } # In order to be more efficient in tag collection, the infrastructure data is filtered as much as possible. # All filters are applied except the ones based on tags of course. resource_filters_without_tags = [ f for f in self . _config . resource_filters if not isinstance ( f , TagFilter ) ] filtered_infra_data = { mor : props for mor , props in iteritems ( infrastructure_data ) if isinstance ( mor , tuple ( self . _config . collected_resource_types ) ) and is_resource_collected_by_filters ( mor , infrastructure_data , resource_filters_without_tags ) } t0 = Timer ( ) mors_list = list ( filtered_infra_data . keys ( ) ) try : mor_tags = self . api_rest . get_resource_tags_for_mors ( mors_list ) except Exception as e : self . log . error ( "Failed to collect tags: %s" , e ) return { } self . gauge ( 'datadog.vsphere.query_tags.time' , t0 . total ( ) , tags = self . _config . base_tags , raw = True , hostname = self . _hostname , ) return mor_tags