### Question:
PrometheusMetricsSystem implements ObservableMetricsSystem { public static ObservableMetricsSystem init(final MetricsConfiguration metricsConfiguration) { if (!metricsConfiguration.isEnabled() && !metricsConfiguration.isPushEnabled()) { return new NoOpMetricsSystem(); } final PrometheusMetricsSystem metricsSystem = new PrometheusMetricsSystem( metricsConfiguration.getMetricCategories(), metricsConfiguration.isTimersEnabled()); if (metricsSystem.isCategoryEnabled(StandardMetricCategory.PROCESS)) { metricsSystem.collectors.put( StandardMetricCategory.PROCESS, singleton(new StandardExports().register(metricsSystem.registry))); } if (metricsSystem.isCategoryEnabled(StandardMetricCategory.JVM)) { metricsSystem.collectors.put( StandardMetricCategory.JVM, asList( new MemoryPoolsExports().register(metricsSystem.registry), new BufferPoolsExports().register(metricsSystem.registry), new GarbageCollectorExports().register(metricsSystem.registry), new ThreadExports().register(metricsSystem.registry), new ClassLoadingExports().register(metricsSystem.registry))); } return metricsSystem; } PrometheusMetricsSystem(
      final Set<MetricCategory> enabledCategories, final boolean timersEnabled); static ObservableMetricsSystem init(final MetricsConfiguration metricsConfiguration); @Override LabelledMetric<org.hyperledger.besu.plugin.services.metrics.Counter> createLabelledCounter(
      final MetricCategory category,
      final String name,
      final String help,
      final String... labelNames); @Override LabelledMetric<OperationTimer> createLabelledTimer(
      final MetricCategory category,
      final String name,
      final String help,
      final String... labelNames); @Override void createGauge(
      final MetricCategory category,
      final String name,
      final String help,
      final DoubleSupplier valueSupplier); void addCollector(final MetricCategory category, final Collector metric); @Override Stream<Observation> streamObservations(final MetricCategory category); @Override Stream<Observation> streamObservations(); String convertToPrometheusName(final MetricCategory category, final String name);  }### Answer:
@Test public void returnsNoOpMetricsWhenAllDisabled() { final MetricsConfiguration metricsConfiguration = MetricsConfiguration.builder().enabled(false).pushEnabled(false).build(); final MetricsSystem localMetricSystem = PrometheusMetricsSystem.init(metricsConfiguration); assertThat(localMetricSystem).isInstanceOf(NoOpMetricsSystem.class); }
@Test public void returnsPrometheusMetricsWhenEnabled() { final MetricsConfiguration metricsConfiguration = MetricsConfiguration.builder().enabled(true).pushEnabled(false).build(); final MetricsSystem localMetricSystem = PrometheusMetricsSystem.init(metricsConfiguration); assertThat(localMetricSystem).isInstanceOf(PrometheusMetricsSystem.class); }
@Test public void returnsNoOpMetricsWhenPushEnabled() { final MetricsConfiguration metricsConfiguration = MetricsConfiguration.builder().enabled(false).pushEnabled(true).build(); final MetricsSystem localMetricSystem = PrometheusMetricsSystem.init(metricsConfiguration); assertThat(localMetricSystem).isInstanceOf(PrometheusMetricsSystem.class); }