def stats_path(values):
    """
    Return the stats path for the given Values object.
    """
    # The filter() call here will remove any None values, so when we join()
    # these to get our stat path, only valid components will be joined.
    return '.'.join(filter(None, [
        # plugin name
        values.plugin,
        # plugin instance, if any
        getattr(values, 'plugin_instance', None),
        # type, if any
        getattr(values, 'type', None),
        # The name of the type instance
        values.type_instance,
    ]))