def METHOD_NAME(aggregator, dd_run_check, mock_performance_objects, mocker, caplog):
    import pywintypes
    error_data = (None, None, 'foo failed')
    mock_performance_objects({'Foo': (['baz'], {'Bar': [9000]})})
    mocker.patch(
        'datadog_checks.base.checks.windows.perf_counters.counter.PerfObject.collect',
        side_effect=pywintypes.error(*error_data),
    )
    check = get_check({'metrics': {'Foo': {'name': 'foo', 'counters': [{'Bar': 'bar'}]}}})
    dd_run_check(check)
    aggregator.assert_all_metrics_covered()
    aggregator.assert_service_check('test.windows.perf.health', ServiceCheck.OK, tags=GLOBAL_TAGS)
    expected_message = 'Error collecting query data for performance object `Foo`: {}'.format(error_data)
    for _, level, message in caplog.record_tuples:
        if level == logging.ERROR and message == expected_message:
            break
    else:
        raise AssertionError('Expected ERROR log with message `{}`'.format(expected_message))