def METHOD_NAME(
    dd_run_check,
    aggregator,
    datadog_agent,
    raw_version,
    version_metadata,
    gitlab_check,
    get_auth_config,
    enable_metadata_collection,
    use_openmetrics,
):
    with mock.patch('datadog_checks.base.utils.http.requests.Response.json') as g:
        # mock the api call so that it returns the given version
        g.return_value = {"version": raw_version}
        datadog_agent.reset()
        datadog_agent._config["enable_metadata_collection"] = enable_metadata_collection
        dd_run_check(gitlab_check(get_auth_config(use_openmetrics)))
        # With use_openmetrics, we also have a request to get the service checks.
        if enable_metadata_collection:
            assert g.call_count == (2 if use_openmetrics else 1)
            datadog_agent.assert_metadata('test:123', version_metadata)
            datadog_agent.assert_metadata_count(5)
        else:
            assert g.call_count == (1 if use_openmetrics else 0)
            datadog_agent.assert_metadata_count(0)