public synchronized void setMetrics(final Traversal.Admin traversal, final boolean onGraphComputer) {
        // this is meant to be called on a traversal that is locked so that the metrics can get initialized
        // properly in all the ProfileStep instances
        if (!traversal.isLocked()) throw new IllegalStateException("Metrics cannot be computed when the traversal is not locked");
        if (finalized) throw new IllegalStateException("Metrics have been finalized and cannot be modified");
        finalized = true;
        handleNestedTraversals(traversal, null, onGraphComputer);
        addTopLevelMetrics(traversal, onGraphComputer);
    }
Extracts metrics from the provided {@link Traversal} and computes metrics. Calling this method finalizes the
metrics such that their values can no longer be modified.
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversalMetrics.java