private void addMonitor(final String elementId,
                            final PipelineElementType elementType,
                            final Element element,
                            final Fragment fragment,
                            final SteppingController controller) {
        final ElementMonitor elementMonitor = new ElementMonitor(elementId, elementType, element);
        if (fragment.getIn() == fragment.getOut()) {
            // In some cases we replace the input and output elements with the
            // same recorder. In these cases we treat the recorder as an output
            // recorder.
            if (fragment.getOut() != null && fragment.getOut() instanceof Recorder) {
                elementMonitor.setOutputMonitor((Recorder) fragment.getOut());
            }
        } else {
            if (fragment.getIn() != null && fragment.getIn() instanceof Recorder) {
                elementMonitor.setInputMonitor((Recorder) fragment.getIn());
            }
            if (fragment.getOut() != null && fragment.getOut() instanceof Recorder) {
                elementMonitor.setOutputMonitor((Recorder) fragment.getOut());
            }
        }

        if (fragment.getOut() != null && fragment.getOut() instanceof SteppingFilter) {
            elementMonitor.setSteppingFilter((SteppingFilter) fragment.getOut());
        }

        controller.registerMonitor(elementMonitor);
    }
If we are in stepping mode then this method will register an element
monitor using the input and output recorders with the stepping
controller.

@param elementId   The id of the element that we are monitoring.
@param elementType The type of the element that we are monitoring.
@param element     The actual element instance that we are monitoring.
@param fragment    The pipeline fragment for the element to be monitored that may
                   include recorders for input and output.
@param controller  The stepping controller.
stroom-pipeline/src/main/java/stroom/pipeline/factory/PipelineFactory.java