@Override
    public void close() {
        registry.ifPresent(r -> Arrays.asList(
            LATEST_SNAPSHOT_GENERATED_BYTES,
            LATEST_SNAPSHOT_GENERATED_AGE_MS
        ).forEach(r::removeMetric));
    }
@Test
    public void testMetricNames() {
        try (SnapshotEmitterMetricsTestContext ctx = new SnapshotEmitterMetricsTestContext()) {
            ControllerMetricsTestUtils.assertMetricsForTypeEqual(ctx.registry, "kafka.server:",
                new HashSet<>(Arrays.asList(
                    "kafka.server:type=SnapshotEmitter,name=LatestSnapshotGeneratedBytes",
                    "kafka.server:type=SnapshotEmitter,name=LatestSnapshotGeneratedAgeMs"
                )));
            ctx.metrics.close();
            ControllerMetricsTestUtils.assertMetricsForTypeEqual(ctx.registry, "KafkaController",
                    Collections.emptySet());
        }
    }