<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def do_perf_counter_check(self, instance):
 """ Fetch the metrics from the sys.dm_os_performance_counters table """

        custom_tags = instance.get('tags', [])
        if custom_tags is None:
            custom_tags = []
        instance_key = self._conn_key(instance, self.DEFAULT_DB_KEY)
        instance_by_key = self.instances_per_type_metrics[instance_key]
        with self.open_managed_db_connections(instance, self.DEFAULT_DB_KEY):
            # if the server was down at check __init__ key could be missing.
            if instance_key not in self.instances_metrics:
                self._make_metric_list_to_collect(instance, self.custom_metrics)
            metrics_to_collect = self.instances_metrics[instance_key]

            with self.get_managed_cursor(instance, self.DEFAULT_DB_KEY) as cursor:
                simple_rows = SqlSimpleMetric.fetch_all_values(cursor, instance_by_key["SqlSimpleMetric"], self.log)
                fraction_results = SqlFractionMetric.fetch_all_values(
                    cursor, instance_by_key["SqlFractionMetric"], self.log
                )
                waitstat_rows, waitstat_cols = SqlOsWaitStat.fetch_all_values(
                    cursor, instance_by_key["SqlOsWaitStat"], self.log
                )
                vfs_rows, vfs_cols = SqlIoVirtualFileStat.fetch_all_values(
                    cursor, instance_by_key["SqlIoVirtualFileStat"], self.log
                )
                clerk_rows, clerk_cols = SqlOsMemoryClerksStat.fetch_all_values(
                    cursor, instance_by_key["SqlOsMemoryClerksStat"], self.log  # noqa: E501
                )

                for metric in metrics_to_collect:
                    try:
                        if type(metric) is SqlSimpleMetric:
                            metric.fetch_metric(cursor, simple_rows, custom_tags)
                        elif type(metric) is SqlFractionMetric or type(metric) is SqlIncrFractionMetric:
                            metric.fetch_metric(cursor, fraction_results, custom_tags)
                        elif type(metric) is SqlOsWaitStat:
                            metric.fetch_metric(cursor, waitstat_rows, waitstat_cols, custom_tags)
                        elif type(metric) is SqlIoVirtualFileStat:
                            metric.fetch_metric(cursor, vfs_rows, vfs_cols, custom_tags)
                        elif type(metric) is SqlOsMemoryClerksStat:
                            metric.fetch_metric(cursor, clerk_rows, clerk_cols, custom_tags)

                    except Exception as e:
                        self.log.warning("Could not fetch metric {} : {}".format(metric.datadog_name, e))