def record_iteration(requester, prob, case_name):
    """
    Record an iteration of the current Problem or Driver.

    Parameters
    ----------
    requester : Problem or Driver
        The recording requester.
    prob : Problem
        The Problem.
    case_name : str
        The name of this case.
    """
    if not requester._rec_mgr._recorders:
        return
    filt = requester._filtered_vars_to_record
    model = prob.model
    inputs, outputs, residuals = model.get_nonlinear_vectors()
    parallel = requester._rec_mgr._check_parallel(
        ) if model.comm.size > 1 else False
    discrete_inputs = model._discrete_inputs
    discrete_outputs = model._discrete_outputs
    data = {'input': {}, 'output': {}, 'residual': {}}
    if requester.recording_options['record_inputs'] and (inputs._names or 
        len(discrete_inputs) > 0):
        data['input'] = model._retrieve_data_of_kind(filt, 'input',
            'nonlinear', parallel)
    if requester.recording_options['record_outputs'] and (outputs._names or
        len(discrete_outputs) > 0):
        data['output'] = model._retrieve_data_of_kind(filt, 'output',
            'nonlinear', parallel)
    if requester.recording_options['record_residuals'] and residuals._names:
        data['residual'] = model._retrieve_data_of_kind(filt, 'residual',
            'nonlinear', parallel)
    from openmdao.core.problem import Problem
    if isinstance(requester, Problem):
        if requester.recording_options['record_derivatives'
            ] and prob.driver._designvars and prob.driver._responses:
            totals = requester.compute_totals(return_format=
                'flat_dict_structured_key')
            data['totals'] = totals
    requester._rec_mgr.record_iteration(requester, data, requester.
        _get_recorder_metadata(case_name))
