@Override
    public void run(DiagnosticsLogWriter writer) {
        metricCollector.writer = writer;
        // we set the time explicitly so that for this particular rendering of the probes, all metrics have exactly
        // the same timestamp
        metricCollector.timeMillis = System.currentTimeMillis();
        metricsRegistry.collect(metricCollector);
        metricCollector.writer = null;
    }
@Test
    public void testRunWithProblematicProbe() {
        metricsRegistry.registerStaticProbe(this, "broken", MANDATORY, (LongProbeFunction) source -> {
            throw new RuntimeException("error");
        });

        plugin.run(logWriter);
        assertContains("[metric=broken]=java.lang.RuntimeException:error");
    }