private LatencyMetrics makeLatencyMetrics() {
        Duration latency = numIntervalsEnded <= 0 ?
                Duration.ZERO :
                Duration.ofNanos(round(cumulativeLatency.toNanos() / (double) numIntervalsEnded));

        Optional<Duration> maxLatencyFromActiveIntervals = activeIntervals.stream()
                .map(ActiveIntervalInfo::startOfIntervalNanos)
                .min(Comparator.comparing(value -> value))
                .map(startOfIntervalNanos -> Duration.ofNanos(endOfPeriodNanos - startOfIntervalNanos));
        Duration maxActiveLatency = maxLatencyFromActiveIntervals
                .filter(latencyCandidate -> latencyCandidate.compareTo(maxLatency) > 0)
                .orElse(maxLatency);

        final double startHz, endHz, load;
        final Map<String, Double> loadByThread = new HashMap<>();
        long periodNanos = endOfPeriodNanos - startOfPeriodNanos;
        if (periodNanos > 0) {
            double periodSeconds = periodNanos / 1_000_000_000.0;
            startHz = numIntervalsStarted / periodSeconds;
            endHz = numIntervalsEnded / periodSeconds;
            load = cumulativeLoadNanos / periodNanos;
            cumulativeLoadNanosByThread.forEach((name, threadLoad) -> {
                if (threadLoad > 0) loadByThread.put(name, threadLoad / (double) periodNanos);
            });
        } else {
            startHz = endHz = 0.0;
            load = activeIntervals.size();
            for (ActiveIntervalInfo activeInterval : activeIntervals) {
                loadByThread.put(activeInterval.threadNameTemplate, 1.0);
            }
        }

        return new LatencyMetrics(latency,
                                  maxLatency,
                                  maxActiveLatency,
                                  startHz,
                                  endHz,
                                  loadByThread,
                                  load,
                                  maxLoad,
                                  activeIntervals.size());
    }
Returns the metrics for the startOfPeriodNanos and endOfPeriodNanos period.
zkfacade/src/main/java/com/yahoo/vespa/curator/stats/LatencyStats.java