public void recordLatency(final String key, final long duration) {
        if (this.metrics != null) {
            this.metrics.timer(key).update(duration, TimeUnit.MILLISECONDS);
        }
    }
Records operation latency.

@param key      key of operation
@param duration duration of operation
jraft-core/src/main/java/com/alipay/sofa/jraft/core/NodeMetrics.java