@Override
    public ScheduledReporter build(MetricRegistry registry) {
        final File directory = requireNonNull(getFile(), "File is not set");
        final boolean creation = directory.mkdirs();
        if (!creation && !directory.exists()) {
            throw new RuntimeException("Failed to create" + directory.getAbsolutePath());
        }

        return CsvReporter.forRegistry(registry)
                          .convertDurationsTo(getDurationUnit())
                          .convertRatesTo(getRateUnit())
                          .filter(getFilter())
                          .formatFor(getLocale())
                          .build(directory);
    }
@Test
    void directoryCreatedOnStartup() throws Exception {
        File dir = new File("metrics");
        dir.delete();
        assertThat(dir).doesNotExist();

        MetricsFactory config = factory.build(new ResourceConfigurationSourceProvider(), "yaml/metrics.yml");
        MetricRegistry metricRegistry = new MetricRegistry();
        config.configure(new LifecycleEnvironment(metricRegistry), metricRegistry);
        assertThat(dir).exists();
    }