private void addNodeMetricsBody(Collection<Pair<String, NodeMetricSnapshot>> snapshots) {
        synchronized (nodeTable.writeLock) {
            try (TableWriter writer = nodeTable.getWriter()) {
                for (var snapshot : snapshots) {
                    Optional<Long> atMillis = nodeTable.adjustOrDiscard(snapshot.getSecond().at());
                    if (atMillis.isEmpty()) continue;
                    TableWriter.Row row = writer.newRow(atMillis.get() * 1000); // in microseconds
                    row.putStr(0, snapshot.getFirst());
                    // (1 is timestamp)
                    row.putFloat(2, (float) snapshot.getSecond().load().cpu());
                    row.putFloat(3, (float) snapshot.getSecond().load().memory());
                    row.putFloat(4, (float) snapshot.getSecond().load().disk());
                    row.putLong(5, snapshot.getSecond().generation());
                    row.putBool(6, snapshot.getSecond().inService());
                    row.putBool(7, snapshot.getSecond().stable());
                    row.putFloat(8, (float) snapshot.getSecond().queryRate());
                    row.putFloat(9, (float) snapshot.getSecond().load().gpu());
                    row.putFloat(10, (float) snapshot.getSecond().load().gpuMemory());
                    row.append();
                }
                writer.commit();
            }
        }
    }
An implementation of the metrics Db backed by Quest:
This provides local persistent storage of metrics with fast, multi-threaded lookup and write,
suitable for production.

@author bratseth
node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/QuestMetricsDb.java