@Override
    public List<MetricFamilySamples> collect() {
        try {
            return exporter.export("Prometheus")
                    .<List<MetricFamilySamples>>map(optional -> Collections.singletonList((GaugeMetricFamily) optional.getRawMetricFamilyObject())).orElse(Collections.emptyList());
            // CHECKSTYLE:OFF
        } catch (final Exception ex) {
            // CHECKSTYLE:ON
            log.warn("Collect metrics error: {}", ex.getMessage());
        }
        return Collections.emptyList();
    }
@Test
    void assertCollectWithPresentMetricsExporter() {
        MetricsExporter exporter = mock(MetricsExporter.class);
        when(exporter.export("Prometheus")).thenReturn(Optional.of(mock(GaugeMetricFamilyMetricsCollector.class)));
        assertThat(new PrometheusMetricsExporter(exporter).collect().size(), is(1));
    }