code: def _compute_needed_metrics(self, instance, available_metrics):
          
          i_key = self._instance_key(instance)
          if self.in_compatibility_mode(instance):
              if instance.get('all_metrics', False):
                  return available_metrics
  
              wanted_metrics = []
              # Get only the basic metrics
              for counter_id in available_metrics:
                  # No cache yet, skip it for now
                  if not self.metadata_cache.contains(i_key, counter_id):
                      self.log.debug(
                          "No metadata found for counter {}, will not collect it".format(ensure_unicode(counter_id))
                      )
                      continue
                  metadata = self.metadata_cache.get_metadata(i_key, counter_id)
                  if metadata.get('name') in BASIC_METRICS:
                      wanted_metrics.append(vim.PerformanceManager.MetricId(counterId=counter_id, instance="*"))
  
              return wanted_metrics
          else:
              # The metadata cache contains only metrics of the desired level, so use it to filter the metrics to keep
              return [
                  vim.PerformanceManager.MetricId(counterId=counter_id, instance="*")
                  for counter_id in available_metrics
                  if self.metadata_cache.contains(i_key, counter_id)
              ]
docs: Compare the available metrics for one MOR we have computed and intersect them
          with the set of metrics we want to report