(self)
Request the list of counters (metrics) from vSphere and store them in a cache.
Request the list of counters (metrics) from vSphere and store them in a cache.
Request the list of counters ( metrics ) from vSphere and store them in a cache .
def refresh_metrics_metadata_cache(self):
        # type: () -> None
        """
        Request the list of counters (metrics) from vSphere and store them in a cache.
        """
        self.log.debug(
            "Refreshing the metrics metadata cache. Collecting all counters metadata for collection_level=%d",
            self._config.collection_level,
        )
        t0 = Timer()
        counters = self.api.get_perf_counter_by_level(self._config.collection_level)
        self.gauge(
            "datadog.vsphere.refresh_metrics_metadata_cache.time",
            t0.total(),
            tags=self._config.base_tags,
            raw=True,
            hostname=self._hostname,
        )
        self.log.debug("Collected %d counters metadata in %.3f seconds.", len(counters), t0.total())

        for mor_type in self._config.collected_resource_types:
            allowed_counters = []
            for c in counters:
                metric_name = format_metric_name(c)
                if metric_name in ALLOWED_METRICS_FOR_MOR[mor_type] and not is_metric_excluded_by_filters(
                    metric_name, mor_type, self._config.metric_filters
                ):
                    allowed_counters.append(c)
            metadata = {c.key: format_metric_name(c) for c in allowed_counters}  # type: Dict[CounterId, MetricName]
            self.metrics_metadata_cache.set_metadata(mor_type, metadata)
            self.log.debug(
                "Set metadata for mor_type %s: %s",
                mor_type,
                metadata,
            )
def refresh_metrics_metadata_cache ( self ) : # type: () -> None self . log . debug ( "Refreshing the metrics metadata cache. Collecting all counters metadata for collection_level=%d" , self . _config . collection_level , ) t0 = Timer ( ) counters = self . api . get_perf_counter_by_level ( self . _config . collection_level ) self . gauge ( "datadog.vsphere.refresh_metrics_metadata_cache.time" , t0 . total ( ) , tags = self . _config . base_tags , raw = True , hostname = self . _hostname , ) self . log . debug ( "Collected %d counters metadata in %.3f seconds." , len ( counters ) , t0 . total ( ) ) for mor_type in self . _config . collected_resource_types : allowed_counters = [ ] for c in counters : metric_name = format_metric_name ( c ) if metric_name in ALLOWED_METRICS_FOR_MOR [ mor_type ] and not is_metric_excluded_by_filters ( metric_name , mor_type , self . _config . metric_filters ) : allowed_counters . append ( c ) metadata = { c . key : format_metric_name ( c ) for c in allowed_counters } # type: Dict[CounterId, MetricName] self . metrics_metadata_cache . set_metadata ( mor_type , metadata ) self . log . debug ( "Set metadata for mor_type %s: %s" , mor_type , metadata , )