def merge_resources(resource_list):
    """Merge multiple resources to get a new resource.

    Resources earlier in the list take precedence: if multiple resources share
    a label key, use the value from the first resource in the list with that
    key. The combined resource's type will be the first non-null type in the
    list.

    :type resource_list: list(:class:`Resource`)
    :param resource_list: The list of resources to combine.

    :rtype: :class:`Resource`
    :return: The new combined resource.
    """
    if not resource_list:
        raise ValueError
    rtype = None
    for rr in resource_list:
        if rr.type:
            rtype = rr.type
            break
    labels = {}
    for rr in reversed(resource_list):
        labels.update(rr.labels)
    return Resource(rtype, labels)
Merge multiple resources to get a new resource.

    Resources earlier in the list take precedence: if multiple resources share
    a label key, use the value from the first resource in the list with that
    key. The combined resource's type will be the first non-null type in the
    list.

    :type resource_list: list(:class:`Resource`)
    :param resource_list: The list of resources to combine.

    :rtype: :class:`Resource`
    :return: The new combined resource.