def check_metrics_provider_content(error_message, name, type, type_details=None):
    """Create a callable to verify the content of a metrics provider in a response
    from the krake API.

    To be used with the :meth:`run` function. The callable will raise an
    :class:`AssertionError` if the content of the metrics provider in the
    response is different from the given one.

    Args:
        error_message (str): the message that will be displayed if the check fails.
        name (str): the expected name of the metrics provider
        type (str): the expected type of the metrics provider
        type_details (str): the expected details of the metrics provider, i.e.,
            the value of spec.<type>.

    Returns:
        callable: a condition that will check its given response against the parameters
            of the current function.

    Raises:
        AssertionError: if the content of the metrics provider in the response is
            different from the given one.
    """
    assert type in ["prometheus", "static", "kafka"], (
        error_message + f" Invalid mp type '{type}'."
    )
    assert type_details, error_message + " No type_details were provided."
    expected_mp = {
        "api": "core",
        "kind": "GlobalMetricsProvider",
        "metadata": {"name": name},
        "spec": {"type": type, type: type_details},
    }

    def validate(response):
        observed_mp = response.json

        details = (
            f"\nExpected spec: {expected_mp['spec']}.\n"
            f"Observed: {observed_mp['spec']}."
        )
        assert observed_mp["spec"] == expected_mp["spec"], error_message + details

        details = (
            f"\nExpected name: {name}.\nObserved: {observed_mp['metadata']['name']}."
        )
        assert observed_mp["metadata"]["name"] == name, error_message + details

    return validate