@Override
        protected void publish() {
            for (var meter : getMeters()) {
                var name = meter.getId().getName();
                if (!ALLOWED_METERS.contains(name)) {
                    log.fine(() -> "Ignoring meter with id '%s'".formatted(meter.getId()));
                    continue;
                }
                var dimensions = new HashMap<String, Object>();
                meter.getId().getTags().forEach(tag -> dimensions.put(tag.getKey(), tag.getValue()));
                var context = jdiscMetric.createContext(dimensions);
                switch (meter.getId().getType()) {
                    case COUNTER -> {
                        if (meter instanceof FunctionCounter fc) {
                            jdiscMetric.set(name, fc.count(), context);
                        } else if (meter instanceof Counter c) {
                            jdiscMetric.set(name, c.count(), context);
                        } else {
                            throw new IllegalArgumentException("Unsupported counter type: " + meter.getClass().getName());
                        }
                    }
                    case GAUGE -> {
                        var gauge = (Gauge) meter;
                        jdiscMetric.set(name, gauge.value(), context);
                    }
                    case TIMER -> {
                        var timer = (Timer) meter;
                        jdiscMetric.set(name, timer.max(TimeUnit.SECONDS), context);
                    }
                    default -> throw new IllegalArgumentException("Unsupported meter type: " + meter.getId().getType());
                }
            }
        }
Publishes JVM metrics from the Micrometer metrics library to JDisc's metric system.

@author bjorncs
container-disc/src/main/java/com/yahoo/container/jdisc/metric/MicrometerMetricReporter.java